Gnuplot堆叠直方图跳过第一个bin

时间:2015-11-06 06:14:14

标签: gnuplot histogram

我正在尝试使用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'

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

非常感谢!

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

1 个答案:

答案 0 :(得分:0)

事实证明,这是一个非常简单的错误,我已经修复了,主要是因为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

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