假设您有以下数据文件:
#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
并且您希望绘制三个具有不同颜色的框图,具体取决于第10列的名称,而您不希望在已扩展的表中添加额外的列以及冗余信息。
通过脚本:
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
并想将linecolor thruogh更改为字典查找位置:
spec => blue
schema => orange
truss => green
你会怎么做?甚至可以翻译spec => GnuPlot中的蓝色?
答案 0 :(得分:1)
使用sed
,您可以添加额外的列,其颜色值对应于最后一列中的单词。你必须绘制两次,第一次在X轴上设置标签,第二次用颜色绘制。
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