Colors Gnuplot中字典查找的可变线颜色
假设您有以下数据文件:Colors Gnuplot中字典查找的可变线颜色,colors,gnuplot,Colors,Gnuplot,假设您有以下数据文件: #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.00
#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
并希望通过字典查找更改线条颜色,其中:
spec => blue
schema => orange
truss => green
你会怎么做?甚至可以在GnuPlot中翻译spec=>blue吗?使用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
恐怕我只是用这段代码得到了紫色:/它可以工作,请参阅编辑后的文章中的图片。如果颜色不适合你,请选择你自己的颜色代码。非常抱歉,我一定是第一次尝试你的代码时做错了什么。它现在起作用了,除了上面可以看到的一个问题:水平中线和最大/最小线消失了。我删除了关键字“胡须”,也许这就是原因。请参见编辑。恐怕盒子内的中间带仍有油漆。如果已经有一个包含颜色的专栏,这会容易得多吗?如果是这样的话,我可以这样做。