具有不同颜色条的 gnuplot 框

标签 gnuplot histogram

我想绘制一个直方图,比如带框的图表。我希望酒吧有不同的颜色。找了一些以前的案例,用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

它应该是这样的:

enter image description here

总之关于using 0:2:4:xticlabels(1)部分:
  • 0告诉 gnuplot 按照它们在文件
  • 中出现的相同顺序放置条形(x 值)
  • 2告诉 gnuplot 从第 2 列中获取 y 值
  • 4告诉 gnuplot 从第 4 列中获取颜色变量
  • xticlabels(1)告诉 gnuplot 从第 1 列
  • 中获取条形的文本标签

    关于具有不同颜色条的 gnuplot 框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28163811/

    相关文章:

    c - 如何在 C 中设置 GNUPLOT 线的颜色

    gnuplot - gnuplot 中的自定义 xtics

    map - gnuplot热图颜色范围

    matlab - 是否可以使用 histogram() 而不是 hist() 在 Matlab 中并排绘制多列直方图

    gnuplot - 在 gnuplot 中读取赤经/赤纬坐标

    arrays - 是否可以使用 gnuplot 以这种格式绘制一系列矩阵

    matlab - 呈现不同颜色的直方图 - matlab

    C-打印直方图

    matrix - 绘制矩阵列的直方图 (Stata 12)

    python - 在 Python 中绘制直方图