是否可以动态更改 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"
生成这个图:
是否可以将低于零的条的颜色设为红色?
谢谢,
斯文
最佳答案
您可以使用 boxes
模仿这种行为。风格:
我的测试数据:
zip 2
baz 2
bar -1
cat 4
foo -3
然后用 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
关于Gnuplot 更改直方图中条的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12224545/