2013-06-04 61 views
0

我試圖用的gnuplot到繪製包含日期,時間和溫度的CSV文件,但它正在產生一些奇怪的結果,當它在圖表中間的工作(主要是隻有一行直線上升)。這是代碼:設置的xrange在gnuplot的產生奇怪的結果

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 

我做錯了什麼?

謝謝

回答

2

這是你的timefmt的定義。
this documentation%s被解釋爲

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

這說明從show xrange輸出爲好。對於這個日期的解釋,你的xrange將空着。

如果使用%Ssecond, 0-60)代替,你的榜樣將繪製精細:

set timefmt '%Y-%m-%d %H:%M:%S' 
+0

非常感謝!我覺得自己像個笨蛋兔子! –

+0

@PhilipKearns不要。像這樣的東西一直都發生在我們所有人身上。 – Schorsch