1

我的数据文件看起来像这样

A 20120301 4
A 20120302 3
B 20120301 5
B 20120302 6
C 20120303 5

除了 A、B、C 之外还有很多,我想用 gnuplot 创建一个堆叠图(类似于gnuplot 演示中的“堆叠直方图” )

20120301 = (A:4 + B:5)
20120302 = (A:3 + B:6)
20120303 = (C:5)

到目前为止,我无法说服 plot 以这种格式读取数据。我是否为此重新安排了数据文件?或者有没有办法让 gnuplot 以这种格式读取数据?

4

1 回答 1

1

我想我已经设法将它打造成一种可行的形式(你至少需要 gnuplot 4.3):

set boxwidth 0.75 absolute
set style fill   solid 1.00 border lt -1
set datafile missing '-'
set style histogram rowstacked
set style data histograms
set yrange [0:]
plot for [i=2:4] 'test.dat' u i,'' u (0.0):xtic(1) notitle

这是数据文件test.dat

#date     A B C
#missing data is marked by a minus sign
20120301  4 5 -   
20120302  3 6 -
20120303  - - 5

呸!在直方图方面,我对 gnuplot 的使用从来都不是很好。希望这对您有用(对您的数据文件的更改感到抱歉)。

于 2012-07-20T03:22:03.577 回答