我想绘制一个直方图,比如带框的图表。我希望酒吧有不同的颜色。找了一些以前的案例,用lc rgb variable
,但这对我不起作用。我的版本仅限于 gnuplot4.2。这是我的数据表:
stage 11402.364 100% 1
App1 78.552 0.69% 2
App2 11323.812 99.30% 2
Read 8.469 0.07% 3
Write 41.285 0.04% 3
Repeat 5748.351 50.41% 3
Count 4933.746 43.27% 3
Count_1 3841.355 33.69% 4
Count_2 1092.391 9.59% 4
这是代码部分:
set boxwidth 0.5 relative
set style fill solid 0.5
set xtics rotate
plot 'histogramdata_2.txt' using 2:xtic(1):4 with boxes variable lc rgb variable notitle
我想使用第 4 列来表示条形颜色。文档中说的第三个数字用在
using
只是颜色变量。但它对我不起作用,结果是没有产生酒吧。看来
using
部分相当灵活。我什至发现这个站点的一些案例在使用后放了 4 个列号。它与不同的版本有关吗?
最佳答案
您的 plot
命令似乎是错误的。请尝试以下操作:
set boxwidth 0.5 relative
set style fill solid 0.5
set xtics rotate
plot 'histogramdata_2.txt' using 0:2:4:xticlabels(1) with boxes lc variable
它应该是这样的:
总之关于
using 0:2:4:xticlabels(1)
部分:0
告诉 gnuplot 按照它们在文件 2
告诉 gnuplot 从第 2 列中获取 y 值 4
告诉 gnuplot 从第 4 列中获取颜色变量 xticlabels(1)
告诉 gnuplot 从第 1 列 关于具有不同颜色条的 gnuplot 框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28163811/