Lets say you have the following data file:
#id count min 1st quart median 3rd quart max sum std-dev name
1 172 0.00032 0.00033 0.00033 0.00033 0.00138 0.05811 0.00008 spec
2 172 0.00039 0.00040 0.00041 0.00042 0.00142 0.07236 0.00008 schema
3 172 0.00007 0.00008 0.00008 0.00009 0.00032 0.01539 0.00003 truss
And you want to draw three box plots with different color depending on which name, column 10, and you'd rather not add an additional column to your already wide table with redundant information.
You've currently got a graph that looks like:
Through the script:
set terminal pdf enhanced size 8cm,8cm font "Verdana 10"
set output "charts/comparison-keyword-".ARG1.".pdf"
set boxwidth 0.2 absolute
set title "Validation comparison for key :".ARG1
set ylabel "milliseconds"
set xrange[0:4]
set yrange[0.00005:50]
set logscale y
set grid y
set tics scale 0
set xtics nomirror
set ytics nomirror
set border 2
set style fill solid 0.25 border -1
set style data boxplot
# Data columns: id count min 1st-quart median 3rd-quart max sum std-dev name
plot "data/comparison-keyword-".ARG1 using 1:4:3:7:6:(0.6):xticlabels(10) with candlesticks linecolor rgb 'orange' title 'Quartiles' whiskerbars, \
'' using 1:4:4:4:4:(0.6) with candlesticks lt -1 notitle
And would like to change the linecolor thruogh a dictionary lookup where:
spec => blue
schema => orange
truss => green
How would you go about it? Is it even possible to translate spec => blue in GnuPlot?
Using sed
, you can add extra column with color values corresponding to the words in the last column. You have to plot it twice, first time to set the labels on the X axis, and second time to plot with colors.
plot "candle.dat" using 1:4:3:7:6:(0.6):xticlabels(10) with candlesticks notitle whiskerbars, \
"< sed 's/spec/spec 0x0000ff/;s/schema/schema 0xff9900/;s/truss/truss 0x00ff00/' candle.dat" using 1:4:3:7:6:(0.6):11 with candlesticks linecolor rgb variable title 'Quartiles' whiskerbars, \
"candle.dat" using 1:4:4:4:4:(0.6) with candlesticks lt -1 notitle