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

Gnuplot stacked histogram skipping the first bin

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

事实证明,这是一个非常简单的错误,由于 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

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