2016-08-23 50 views
0

我正在開發一個腳本,用於讀取有關設備功耗的歷史信息,並打印出具有該點的曲線。我已經設置了X軸來顯示日期時間。我這樣做:Gnuplot不會在X軸上打印年份

# source and filename are both variable names. 
set xdata time 
set terminal pngcairo enhanced font "arial,10" fontscale 1.0 size 900, 350 
set output filename 
set key bmargin left horizontal Right noreverse enhanced autotitles box linetype -1 linewidth 1.000 

# We set the datetime format 
set timefmt '"%Y-%m-%d %H:%M:%S"' 

set datafile missing 'None' 
set style line 1 lt 2 lc rgb 'blue' lw 1 
set style line 2 lt 2 lc rgb 'green' lw 1 
set style line 3 lt 2 lc rgb 'red' lw 1 
set style line 4 lt 2 lc rgb 'green' lw 1 
plot source using 1:2 ls 1 with lines, source using 1:3 ls 2 with lines,source using 1:4 ls 3 with lines 

這工作正常,但在x軸不顯示年的標籤。這是爲什麼發生?我沒有正確設置?我首先生成一個.dat文件,其中包含每個點的一行。我打電話從蟒蛇的GNUPLOT腳本後,可以在文件似乎:

..................... 
"2016-08-22 04:00:00" 1812.44580078 2600.0 800 
"2016-08-22 04:15:00" 1859.58398438 2600.0 800 
"2016-08-22 04:30:00" 1785.85595703 2600.0 800 
..................... 

這是圖的樣子:

enter image description here

我怎麼能實現呢?提前致謝。

回答

1

timefmt只設置輸入時間格式。要設置標籤格式,請使用

set format x "%Y-%m-%d %H:%M:%S" 
+0

謝謝!這種格式正確的日期。 –