【问题标题】:Gnuplot stacked histogram skipping the first binGnuplot 堆叠直方图跳过第一个 bin
【发布时间】:2016-02-07 05:36:26
【问题描述】:

我正在尝试使用 gnuplot 绘制一些数据的堆叠直方图,但它跳过了第一个 bin(数据文件的第一行)。

数据为:

1 0.2512 0.0103 0.9679
2 0.4730 0.2432 0.8468
3 0.6669 0.2826 0.6895
4 0.6304 0.2268 0.7424

情节代码是

set title "Data"
set key invert reverse Left outside
set key autotitle columnheader
set style data histogram
set style histogram rowstacked
set style fill solid border -1
#set boxwidth 0.75

plot 'data.dat' using 2:xtic(1) title 'X', '' using 3 title 'Y', '' using 4 title 'Z'

输出为。我检查了它,它正确显示了数据文件的第 2、3、4 行的数据。为什么我错过了第一个垃圾箱..?

非常感谢!

我已经在没有帮助的情况下检查了这个:Using gnuplot for stacked histograms

【问题讨论】:

  • 为什么是set key autotitle columnheader
  • 可能从旧的剪切和粘贴中结束,并没有做太多你是对的.. 删除它并且情节行中的标题表明 gnuplot 将第一行作为标题列,因此添加一个标题为第一行的虚拟行解决了问题
  • 我真的不知道为什么这个问题被否决了。我觉得这真的很有用!

标签: gnuplot histogram


【解决方案1】:

事实证明,这是一个非常简单的错误,由于 Azad 对标题的评论,我已经修复了这个错误。

新代码是:

set title "Position error along the three axis"
set key invert reverse Left outside
#set key autotitle columnheader
set style data histogram
set style histogram rowstacked
set style fill solid border -1
#set boxwidth 0.75

plot 'data.dat' using 2:xtic(1), '' using 3, '' using 4 

标题已从代码中删除。 Gnuplot 将第一行(应该是第一个 bin)作为标题,然后被 title 'X' 等覆盖。

新数据如下所示:

0 X Y Z
1 0.2512 0.0103 0.9679
2 0.4730 0.2432 0.8468
3 0.6669 0.2826 0.6895
4 0.6304 0.2268 0.7424

这解决了问题,现在所有的垃圾箱都正确显示了!

【讨论】: