Andersnk
Andersnk

Reputation: 867

Box and whisker plot GNUPLOT

I need to visualize some data I have, with box and whisker plots, and I'd like to do it in GNUPLOT. So far I have converted my data to what I have understood is needed for GNU plot. The minimum, first quartile, median, third quartile and max.

This is the data I have:

 #x min     Q1          median      q3          max     width   label
 1  9.9     10.25       10.7        10.975      11.3    0.3     100
 2  23.5    25.525      26.05       27.85       29.1    0.3     200
 3  37.5    40.8        43.65       44.35       45.7    0.3     300
 4  55      58.25       58.65       61.875      65.9    0.3     400
 5  71.3    73.65       75.25       77.4        80.1    0.3     500
 6  73.6    83.85       86.05       88.775      97.5    0.3     600
 7  85.8    89.45       97.3        103.75      106     0.3     700
 8  102     111         112         115.5       119     0.3     800
 9  116     127         128         134         141     0.3     900
 10 126     134         136         140.25      146     0.3     1000
 11 144     149         152         156.25      165     0.3     1100
 12 144     151.25      154         158         166     0.3     1200
 13 138     157.25      159         162         171     0.3     1300
 14 155     161.25      165.5       170         173     0.3     1400
 15 158     171         172.5       177.5       182     0.3     1500

I have made this graph in Excel

enter image description here

But I need to have more graphs in the same image, which is something I cannot do in Excel. I have been messing around with GNUPLOT for a couple of hours, trying to use candlesticks, but all the graphs I get are wrong!

I've uploaded my data-file to DROPBOX https://dl.dropboxusercontent.com/u/12340447/data.txt

Any help is greatly appreciated!

EDIT:

I should probably include the script I currently have

 set bars 2.0
 set style fill empty
 plot 'data.txt' using 1:3:2:6:5:xticlabels(7) with candlesticks title 'Quartiles' whiskerbars, \
    ''         using 1:4:4:4:4 with candlesticks lt -1 notitle

This gives the ouput

enter image description here

There's a few thing wrong with the picture: First of all the labels are wrong. They all say 0.3, but that's supposed to the the width of the boxplots. I'd also like to add a line (as in the excel) from each mean value, marked with a dot or cross or something.. Basically, make it look a little more like the Excel output.

Again - any help is greatly appreceiated!

Upvotes: 2

Views: 8615

Answers (1)

parkydr
parkydr

Reputation: 7784

The labels were wrong because they need to come from column 8 (xticlabels(8)) in the data. The last line adds a blue line (lt 3), with diamond points (pt 13)

set bars 2.0
set style fill empty
plot 'data.txt' using 1:3:2:6:5:xticlabels(8) with candlesticks title 'Quartiles' whiskerbars, \
    ''         using 1:4:4:4:4 with candlesticks lt -1 notitle, \
    ''         using 1:4 with linespoints lt 3 pt 13 notitle

Upvotes: 4

Related Questions