Each graph has nuances that make it a better deal to use separate Gnuplot scripts to generate each graphic.
24 Hour Forecast:
- Code: Select all
#! /usr/bin/env gnuplot
reset
set terminal pngcairo enhanced background "#000000" font "Lato-Light,9" linewidth 1 rounded size 600,200
set output "/Users/......./Dropbox/Public/hourlyForecast.png"
dataFileForecast = "/Users/......./Dropbox/Public/hourlyForecast.csv"
set datafile separator ','
set timefmt "%Y-%m-%d %H:%M"
stats dataFileForecast using 2 nooutput
freezeWarning = 32.
Yhigh = STATS_max + 10.
Ylow = STATS_min - 10.
freezeLabel = ((freezeWarning-Ylow) / (Yhigh-Ylow))
unset key
set border linetype rgb "#666666"
set boxwidth 0.25 relative
set style fill transparent solid 0.4
set style line 1 linetype rgb "#666666"
set style line 2 linetype rgb "#FFFFFF" pointtype 7 pointsize .5
set style line 3 linetype rgb "#0066CC"
set style line 4 linetype rgb "#FFFF00"
unset mxtics
set tics textcolor rgb "#666666"
# X Axis
set xdata time
set xtics format "%l:00 %p" nomirror
set autoscale xfix
set offsets 60*60,60*60,0,0
# Post the label "32°" if it will appear on the graph (based on dynamic Y range)
if (32 > Ylow) set label "32°" at graph 0.01,freezeLabel tc rgb "#FFFFFF" font ",8"
# Y Axis
set ytics format "%2.0f°" nomirror
set yrange [Ylow:Yhigh]
unset ytics
# Y2 Axis
set y2tics format "%2.0f%%" nomirror
set y2range [0:100]
plot dataFileForecast using 1:3 with impulses linestyle 4 axes x1y2,\
dataFileForecast using 1:2 with filledcurve above y1=0 linestyle 1 axes x1y1,\
dataFileForecast using 1:2 with points linestyle 2 axes x1y1,\
dataFileForecast using 1:2:4 with labels offset 0,0.75 textcolor "#FFFFFF" font ",8" axes x1y1,\
freezeWarning with filledcurve above y1=0 linestyle 3 axes x1y1
10 Day Forecast:
- Code: Select all
#! /usr/bin/env gnuplot
reset
set terminal pngcairo enhanced background "#000000" font "Lato-Light,9" linewidth 1 rounded size 600,200
set output "/Users/......./Dropbox/Public/10DayForecast.png"
dataFileForecast = "/Users/......../Dropbox/Public/10DayForecast.csv"
set datafile separator ','
set timefmt "%Y-%m-%d"
stats dataFileForecast using 2:4 nooutput
freezeWarning = 32.
Yhigh = STATS_max_x + 10.
Ylow = STATS_min_y - 10.
freezeLabel = ((freezeWarning-Ylow) / (Yhigh-Ylow))
unset key
set border linetype rgb "#666666"
set boxwidth 0.25 relative
set style fill transparent solid 0.4
set style line 1 linetype rgb "#0066CC"
set style line 2 linetype rgb "#FFFFFF" pointtype 7 pointsize .5
set style line 3 linetype rgb "#666666"
set style line 4 linetype rgb "#FFFF00"
set style line 5 linetype rgb "#333333"
set label "°" right
unset mxtics
set tics textcolor rgb "#666666"
# X Axis
set xdata time
set xtics format "%a" nomirror
set autoscale xfix
set offsets 12*60*60,12*60*60,0,0
# Y Axis
set ytics format "%2f°" nomirror
set yrange [Ylow:Yhigh]
unset ytics
if (32 > Ylow) set label "32°" at graph 0.01,freezeLabel tc rgb "#FFFFFF" font ",8"
# Y2 Axis
set y2tics format "%2.0f%%" nomirror
set y2range [0:100]
plot dataFileForecast using 1:6 with impulses linestyle 4 axes x1y2,\
dataFileForecast using 1:2 with filledcurves above y1=0 linestyle 5 axes x1y1,\
dataFileForecast using 1:2 with points linestyle 2 axes x1y1,\
dataFileForecast using 1:2:3 with labels offset 1.75,0.5 textcolor "#FFFFFF" font ",8" axes x1y1,\
dataFileForecast using 1:4 with filledcurves above y1=0 linestyle 3 axes x1y1,\
dataFileForecast using 1:4 with points linestyle 2 axes x1y1,\
dataFileForecast using 1:4:5 with labels offset 1.75,0.5 textcolor "#FFFFFF" font ",8" axes x1y1,\
freezeWarning with filledcurve above y1=0 linestyle 1 axes x1y1
I call both scripts (along with many others) from a Python script which generates new PNG images every 15 minutes. Then, it's a simple matter of plugging them into a control page. If anyone has any questions about script elements, or suggestions for improvements, feel free to post them here. I am by no means a Gnuplot expert, but can explain the elements I use.
Dave