I'm using a C++ program to automate a lot of plots with Gnuplot. I am making boxplots using the candlestick plot style, and I add median and mean by adding modified candlestick plots, based on the example in the manual:
plot ’stat.dat’ using 1:3:2:6:5 with candlesticks title ’Quartiles’, \
’’ using 1:4:4:4:4 with candlesticks lt -1 notitle
This works, but the key looks funny, because the Mean and Median are drawn as rectangles in the key, even though they appear as lines on the plot. Here is an example:
Is there an easy way to make the key display lines instead of rectangles?
Possible solutions could include plotting the mean and median as lines instead of candlesticks, but I would need to calculate the X positions of each start and stop point. Another solution could include drawing the key manaually using labels and lines. But these could be complex and not very flexible, so I'd thought to ask if any simpler solutions exist.
You can fake key entries by plotting "invisible" lines:
set terminal pngcairo
set output "candle_lines.png"
set boxwidth 0.4 relative
set xrange [0:4]
set yrange [0:100]
plot 'stat.dat' using 1:3:2:6:5 with candlesticks title 'Quartiles', \
'' using 1:4:4:4:4 with candlesticks lt -1 notitle, \
'' using 1:7:7:7:7 with candlesticks lt 0 notitle, \
NaN with lines title "Mean" lt -1, \
NaN with lines title "Median" lt 0
My stat.dat:
1 40 50 63 65 70 57
2 50 60 67 75 80 63
3 30 40 53 55 60 47