Gnuplot在直方图中改变条形的颜色

Sve*_*ger 14 gnuplot histogram

是否可以动态更改Gnuplot脚本中的条形颜色?我有以下脚本

reset
fontsize = 12
set term postscript enhanced eps fontsize
set output "bargraph_speedup.eps"
set style fill solid 1.00 border 0
set style histogram
set style data histogram
set xtics rotate by -45
set grid ytics linestyle 1
set xlabel "Benchmarks" font "bold"
set ylabel "Relative execution time vs. reference implementation" font "bold"
set datafile separator ","
plot 'bm_speedup.dat' using 2:xtic(1) ti "Speedup" linecolor rgb "#00FF00"
Run Code Online (Sandbox Code Playgroud)

这会产生这个情节:

生成的情节

是否可以使零度以下的条形颜色变为红色?

谢谢,
斯文

mgi*_*son 10

您可以使用boxes样式模仿此行为:

我的测试数据:

zip 2
baz 2
bar -1
cat 4
foo -3
Run Code Online (Sandbox Code Playgroud)

然后用gnuplot绘图:

set style line 1 lt 1 lc rgb "green"
set style line 2 lt 1 lc rgb "red"
set style fill solid
plot 'test.dat'  u (column(0)):2:(0.5):($2>0?1:2):xtic(1) w boxes lc variable
#                  #xval:ydata:boxwidth:color_index:xtic_labels
Run Code Online (Sandbox Code Playgroud)