我有一个简单的时间序列:
2015-05-03 07:00,58
2015-05-03 08:00,61
2015-05-03 09:00,65
2015-05-03 10:00,69
2015-05-03 11:00,72
2015-05-03 12:00,74
2015-05-03 13:00,76
2015-05-03 14:00,78
2015-05-03 15:00,78
2015-05-03 16:00,78
2015-05-03 17:00,77
2015-05-03 18:00,76
2015-05-03 19:00,73
2015-05-03 20:00,70
2015-05-03 21:00,67
2015-05-03 22:00,66
2015-05-03 23:00,64
2015-05-04 00:00,63
2015-05-04 01:00,62
2015-05-04 02:00,62
2015-05-04 03:00,61
2015-05-04 04:00,61
2015-05-04 05:00,60
2015-05-04 06:00,60
使用:
reset
set terminal pngcairo enhanced background "#000000" font "Arial,10" size 600,200 truecolor
dataFileForecast = "/Users/.../Dropbox/Public/hourlyForecast.csv"
set datafile separator ','
stats dataFileForecast using 2 nooutput
freezeWarning = 32
Yhigh = (STATS_mean * 1.5)
Ylow = (STATS_mean - (STATS_mean * 0.5))
set timefmt "%Y-%m-%d %H:%M"
set output "/Users/.../Dropbox/Public/hourlyForecast.png"
set tics tc rgb "#666666"
set border lt rgb "#666666"
set boxwidth 0.25 relative
set style fill transparent solid 0.4
set style line 1 lt rgb "#666666" lw 1 pt 6
set style line 2 lt rgb "#0000FF" lw 1 pt 6
unset key
unset mxtics
set xdata time
set xtics format "%H:%M"
set ytics format "%2.0f"
set yrange [Ylow:Yhigh]
plot dataFileForecast using 1:2 every ::1 title column with filledcurve above y1=0 ls 1,\
dataFileForecast using 1:2:2 every ::1 with labels offset 0,1 tc "#FFFFFF" font "Lato-Light,8",\
freezeWarning with filledcurve above y1=0 ls 2
可以,但是由于某种原因我丢失了第一个数据点(绘图应从07:00开始,并显示24个数据点):
我无法弄清楚如何使绘图从第一个数据点开始。(完成此操作后,我真正想做的是在任一侧放一个1小时的缓冲区-换句话说,让xrange为[dataPoint1-(60 * 60):dataPoint24 +(60 * 60)]
非常感激任何的帮助。
戴夫
使用,title column
您告诉gnuplot将第一行用作关键标题。并以此跳过第一行的绘图。然后,该every ::1
零件还将跳过第一行。删除两者,您将获得预期的情节。
要将xrange延伸到每一侧1小时,请set offsets 60*60,60*60,0,0
与一起使用set autoscale xfix
:
reset
set terminal pngcairo enhanced background "#000000" font "Arial,10" size 600,200 truecolor
dataFileForecast = "test.dat"
set datafile separator ','
stats dataFileForecast using 2 nooutput
freezeWarning = 32
Yhigh = (STATS_mean * 1.5)
Ylow = (STATS_mean - (STATS_mean * 0.5))
set timefmt "%Y-%m-%d %H:%M"
set output "test.png"
set tics tc rgb "#666666"
set border lt rgb "#666666"
set boxwidth 0.25 relative
set style fill transparent solid 0.4
set style line 1 lt rgb "#666666" lw 1 pt 6
set style line 2 lt rgb "#0000FF" lw 1 pt 6
unset key
unset mxtics
set xdata time
set xtics format "%H:%M"
set ytics format "%2.0f"
set yrange [Ylow:Yhigh]
set autoscale xfix
set offsets 60*60,60*60,0,0
plot dataFileForecast using 1:2 with filledcurve above y1=0 ls 1,\
dataFileForecast using 1:2:2 with labels offset 0,1 tc "#FFFFFF" font "Lato-Light,8",\
freezeWarning with filledcurve above y1=0 ls 2
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句