I need to plot two data file in the same graph, with gnuplot. The first data file is like:
2015-02-10 10.1
2015-02-15 12.1
2015-02-20 16.1
2015-02-25 14.1
...
and the second data file is like
2015-02-10-10:00 12.5
2015-02-10-15:00 21.4
2015-02-15-12:30 08.3
2015-02-15-22:00 09.3
2015-02-20-08:15 12.8
2015-02-20-17:32 16.7
2015-02-25-07:20 14.0
2015-02-25-21:39 14.5
..
To parse the first data file, timefmt
should be set to "%Y-%m-%d"
and for the second file it would be "%Y-%m-%d-%H:%M"
. However, since both data files should be ploted together, how do I define timefmt
properly?
With verrsion 4.6 and earlier you must parse the datetime strings 'manually' with
strptime
:With gnuplot version 5 you can directly give a time format to the
timecolumn
function, so that you can use as much formats as you want:In your case the difference between the two variants is marginal, but when the date time spreads over more than one column in the data file, then the latter variant is much more comfortable, since
timecolumn
handles the multiple columns automatically.