I'm learning gnuplot by working on tidal data, in monthly files, in this format:
2011/03/01 Tue 08:42 9.39 H
2011/03/01 Tue 15:04 0.2 L
2011/03/01 Tue 21:18 8.67 H
2011/03/02 Wed 03:16 0.71 L
2011/03/02 Wed 09:31 9.51 H
2011/03/02 Wed 15:49 0.09 L
2011/03/02 Wed 22:01 8.91 H
2011/03/03 Thu 04:01 0.48 L
2011/03/03 Thu 10:14 9.58 H
2011/03/03 Thu 16:28 0.05 L
2011/03/03 Thu 22:39 9.11 H
All is well so far: I can output stacked plots into PDF with the multiplot layout setup, BUT I'd like to have the weekly plots always run Monday-Sunday.
With fractional weeks, especially the first week, how can I do this? I can set the xrange manually, but it would need to be re-done for each weekly plot command.
What I'd like to figure out is two things:
- a way to handle the first week problem;
- a way to automate the xrange for each succeeding week (i.e., have gnuplot parse the timestamp and start a new plot each Monday? Can I perhaps do this using the ternary operator?)
Setup:
gnuplot: version 4.4 patchlevel 2
OSX 10.6.6
Setup & plot commands:
set timefmt "%Y/%m/%d-%H:%M"
set origin 0,0
set xdata time
unset key
set samples 1000
myDate(col1,col3)=sprintf("%s-%s",strcol(1),strcol(3))
set grid noxtics
set xtics nomirror font "Arial,10" tc rgb "blue"
set xtics offset 0,0 # required for position of tic labels when stacked.
set yrange [-3:13]
set ytics 3
set grid ytics back
set x2data time
set x2tics 86400
set grid x2tics back
set x2tics 86400
set format x2 "%d" # displays number of day of month
set x2tics offset 3.5,-3 font "Helvetica,20" # required for position of numbers when stacked.
#### set size 1,.2 # un-comment for setting up stacked layout.
set tmargin 3 # gives adequate room between each row of days + labels.
set lmargin 5
set bmargin 2
set rmargin 2
plot 'MonthlyTideDataMarch.txt' u (myDate(1,3)):4:xticlabels(strcol(4) . " \n" . strcol(3) ) lc rgb "green" lw 3 sm cspl notitle