gnuplot box and whiskers plot
Every time I use gnuplot, I am amazed at how difficult it is to conjure up the simplest graphs, so when I finally get to the bottom of one, I’ll try to post the solution here as a reference for myself, and anyone else who might come looking.
If you’re new to gnuplot, you might want to get out now while you still can
The box and whiskers plot
There are a few different styles of box and whiskers plots and this link gives a pretty good description.
The two gotchas for were what values you need and in what order. These scripts are set up to use the following columns, in order:
- X value (for ordering left-right across the graph)
- Min
- 1st Quartile
- Median
- 3rd Quartile
- Max
The other gotcha I had was wanting to have labels across the x-axis rather than numbers. To accomplish this, I added a 7th column with the label, then I used the following:
set xrange[0:3] set yrange[0:10] # Data columns: X Min 1stQuartile Median 3rdQuartile Max Titles set bars 4.0 set style fill empty plot 'data.csv' using 1:3:2:6:5:xticlabels(7) with candlesticks title 'Quartiles' whiskerbars, \ '' using 1:4:4:4:4 with candlesticks lt -1 notitle
The xticlabels(7) is the key to the x-axis labels, saying to use the values from column 7 for the labels.
I am probably being abit thick but what is the extra using for (using 1:4:4:4:4 with candlesticks lt -1 notitle)
Thanks
Your article was a huge help !
Thank you so much! That was awesome, helped me a lot!
For those who read this, just remember to notice that he doesn’t put the mean value (median) on the first line of the command. Instead, he puts it on the 2nd line, which gives us little dashes on the middle of the boxes.