2014-01-06 117 views
1

我對x軸上的日期有(對我來說)一個奇怪的問題。Gnuplot,在x軸上的日期問題

我在第一列使用(imo)linux時間;

1385856000,1.69,0,10.33,0,1.69,10.33,-8.64,12.14,3.5 
1385942400,0,0.94,3.33,8.51,0.94,11.84,-10.9,13.7,2.8 
1386028800,0,0.51,4.96,8.65,0.51,13.61,-13.1,15.8,2.7 
1386115200,0,0.01,3.42,6.49,0.01,9.91,-9.9,10.6,0.7 
V 
V 
V 
1388361600,0,0.63,4.21,7.65,0.63,11.86,-11.23,13.93,2.7 
1388448000,0,0.18,4.47,8.29,0.18,12.76,-12.58,14.48,1.9 

在這種情況下,2013年12月31日。但是該行從30(十一月?)開始。 現在畫一個「30」的矩形,但當然不是這樣。

這是我的腳本;

maand = "Dec" 
jaar = "2013" 
file = maand.jaar.'.txt' 
set output maand.jaar.".png" 
set datafile separator "," 
set linestyle 1 lt 1 lc rgb "black" 
set linestyle 2 lt 1 lc rgb "red" 
set bmargin 2.2 # witruimte onder grafiek 
set label font "arial, 7" # grootte font tbv labels in het grafiek 
set boxwidth 0.8 relative 

set terminal pngcairo truecolor enhanced size 1200, 500 background rgb "#FFF5F5" 

stats file using 0 nooutput ; dagen = STATS_records 

stats file using 10 nooutput ; zon = value(int(STATS_sum*1000)) 
stats file using 9 nooutput ; gebruikt = value(int(STATS_sum*1000)) 
afgenomen = gebruikt-zon 

set timefmt "%s" ; fmt = "%s" 
stats file using (strptime(fmt, stringcolumn(1))) every ::1::1 nooutput 
maand = strftime("%B", STATS_max) ; jaar = strftime("%Y", STATS_max) ; datum = maand." ".jaar 
set title 'Energie stromen '.datum font "arial bold, 14" 

set xdata time ; set timefmt "%s" ; set format x "%d" # dit is de opmaak zoals je hem gaat zien 

set xtics 86400 font "arial,12" offset -1.35,0.5 
set mxtics 1 
set grid ls 1 lc rgb "#dddddd" 
set ytics font "arial, 12" offset 0.5,0 

set ylabel "V e r m o g e n in kW" offset 3,1 font "helvetica, 12" 

unset key 
set key below left samplen 2 
set key maxrows 1 # aantal regels onder het grafiek (met Watt/uur erin) 

set style fill solid 1 border 0.5 # was transparent solid 0.5 border 0.5 

set style rectangle fc linestyle 1 fs solid 0.5 noborder 
set object rectangle front fillcolor rgb "#FFF5F5" 

set object 2 rect from graph -.48, graph -1.5 to graph -0.004, graph 0.02 fc rgb "#FFF5F5" 

plot file u ($1-43200):10 w boxes lc rgb "#00ff00" title "Deze maand zon: ".(zon/1000)." kW",\ 
    file u ($1-43200):10:(sprintf("%2.1f",$10)) w labels offset 0.0,0.4 font "arial, 10" notitle,\ 
    file u ($1-43200):(-1*$9) w boxes lc rgb "#ff0000" title "&{2}Verbruik: ".(gebruikt/1000)." kW",\ 
    file u ($1-43200):(-1*$9):(sprintf("%2.1f",$9)) w labels offset 0,-0.4 font "arial, 10" notitle 

是否有一個人?

screenshot

回答

1

30來自十一月的方式,你卻將xticlabels。

我認爲,有下面的箱子標籤的最佳方式,但抽搐和網格線的框之間如下:

  1. 規模的主要控制點爲0
  2. 添加一個小小的xtic並繪製網格線只對未成年人xtics
  3. 不要在他們的實際時間位置展開自動的xrange到下一個主要抽動(set autoscale xfix
  4. 情節盒(plot file u 1:...,而不是plot file u ($1-43200):...
... 
set xtics 86400 font "arial,12" scale 0, 1 
set mxtics 2 
set grid mxtics ytics ls 1 lc rgb "#dddddd" 
set autoscale xfix 
... 
plot file u 1:10 w boxes lc rgb "#00ff00" 
... 

有了這些修改,您的典型數據和版本4.6.3,我得到

enter image description here

BTW:你可以壓縮你的三個stats調用單次一個:

stats file using 9:10 nooutput 
dagen = STATS_records 
zon = int(STATS_sum_y*1000) 
gebruikt = int(STATS_sum_x*1000) 
+0

兩種解決方案都很完美!很好的幫助。 – Con