0

我试图使用 gnuplot 来绘制一个包含日期时间和温度的 CSV 文件,但它在工作时会产生一些奇怪的结果(主要是图表中间的一条直线)。这是代码:

set xdata time
set timefmt '%Y-%m-%d %H:%M:%s'
set xrange["2013-05-29 00:00:00":"2013-06-04 00:00:00"]
set datafile separator ','
plot 'weather.csv' using 1:2

这是一个数据样本:

2013-05-29 18:30:00,20.0
2013-05-29 21:29:00,14.0
2013-05-29 22:29:00,13.0
2013-05-29 23:29:00,12.0
2013-05-30 08:28:00,13.0
2013-05-30 09:30:00,14.0

出现错误:

Can't plot with an empty x range!

所以我在命令行输入了命令:

gnuplot> set xdata time
gnuplot> set timefmt '%Y-%m-%d %H:%M:%s'
gnuplot> set xrange["2013-05-29 00:00:00":"2013-06-04 00:00:00"]
gnuplot> show xrange

        set xdata time
        set xrange [ "1970-01-01 00:00:-946684800" : "1970-01-01 00:00:-946684800" ] noreverse nowriteback

gnuplot> show

我究竟做错了什么?

谢谢

4

1 回答 1

2

这是你的timefmt定义。
根据这个文档%s被解释为

seconds since the Unix epoch (1970-01-01 00:00 UTC)

这也解释了您的输出show xrange。对于这个日期解释,你的xrange将是空的。

如果您使用%S( second, 0-60) 代替,您的示例将绘制得很好:

set timefmt '%Y-%m-%d %H:%M:%S'
于 2013-06-04T16:07:33.190 回答