2

I'm trying to draw the outliers for my boxplot diagram with pgfplots. I've managed to draw the actual boxes so now I am trying to draw a simple scatter diagram. I have a couple of tables that looks as follows:

n            median       Q3           Q1           UW           LW           mean         min          max          outliers
12           1.952017     2.030306     1.893512     2.065810     1.879817     1.959266     1.879817     2.065810     {}
24           1.878986     1.922025     1.836832     1.965843     1.787341     1.919280     1.787341     2.932309     {2.932309}
36           2.080509     2.187772     2.038786     2.315607     1.944424     2.108413     1.944424     2.315607     {}
72           3.902994     4.103200     3.658043     4.763806     3.427024     3.972250     3.427024     5.040159     {5.040159, 4.905358, 4.856334, 4.821004, 4.789719, 4.775229}

The naive approach of doing \addplot+[scatter, only marks] table[x={n}, y={outliers}] {data.dat}; of course didn't work because outliers aren't a single value. I've tried using \foreach but honestly I have no idea what I'm doing.

Any help would be greatly appreciated!

Edit: I took the easy way and wrote a script to extract the outliers and simply plotted them.

  • You could copy the outliers into a macro using \pgfplotstablegetelem, but you would have to reformat the list into x,y coordinates for a scatter plot, or just plot each outlier separately using a \foreach loop. – John Kormylo Sep 27 '16 at 14:47
  • Would you like to provide a minimal working example? Or at least a setup of PGPLOTS? Because at least you will get answers typeset in your style. – Symbol 1 Sep 30 '16 at 13:49

1 Answers1

1

I "solved" this problem by writing a simple script to extract the outliers in a separate table.

#!/usr/bin/perl

for( <> ) {
      if( /(\d+).*{((?:\d+\.?\d*,? ?)+)}/ ) {
            my $x = $1;
            for( split(/, /,$2) ) {
                    print "$x\t$_\n";
            }
      }
}