gnuplot更改直方图中条形的颜色 [英] Gnuplot change color of bars in histogram
本文介绍了gnuplot更改直方图中条形的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以动态更改Gnuplot脚本中的条形颜色? 我有以下脚本
is it possible to change the color of bars in a Gnuplot script dynamically? I have the following script
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"
生成此图:
是否可以将零以下的条形颜色变成红色?
Is it possible to make the color of the bars which are below zero red?
谢谢,
斯文
Thanks,
Sven
推荐答案
您可以使用boxes
样式模仿此行为:
You can mimic this behavior using the boxes
style:
我的测试数据:
zip 2
baz 2
bar -1
cat 4
foo -3
然后使用gnuplot进行绘图:
And then plotting with 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更改直方图中条形的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文