Lets' take this as the data file:
2012-06-01, 01:00, 1
2012-06-01, 02:00, 2
2012-06-01, 03:00, 4
2012-06-01, 04:00, 3
...
2012-06-02, 01:00, 5
2012-06-02, 02:00, 2
2012-06-02, 03:00, 1
2012-06-02, 04:00, 1
...
I know how to set timefmt
and xdata
to plot time series when date and time are represented with a single field, but how to plot this with GnuPlot when time and date are stored in separate columns?
Not too differently than you would if they were spaces...
set timefmt '%Y-%m-%d, %H:%M'
set xdata time
set datafile sep ','
plot 'test.dat' u 1:3 w lines
I don't know if you've used timefmt with spaces in it before either (for regular space separated datafiles) but in that case, you specify the column where the time-data starts -- gnuplot automatically looks however many columns it needs to fill out the full time format. Of course, you need a full using specification (in this case that means designating that the data is in the 3rd column -- note, not the second as you might expect).
(tested on gnuplot 4.4 -- OS X)
Running Arch Linux Gnuplot 4.6 patchlevel 3
I couldn't get mgilson's code snippet to work.
I needed to set the xrange
before it would stop complaining
all points y value undefined!
I had to
set xrange["2012-06-01, 01:00":"2012-06-02, 05:00"]
and finally got a pretty plot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With