Re: plotting time series data
Roderick Stewart <[email protected]>
| Newsgroups | gmane.comp.graphics.gnuplot.user |
|---|---|
| Message-ID | <[email protected]> |
thanks to all for your help. Ethan’s suggestion works great. Rod -- Roderick Stewart Research Fellow (Volcano-Seismology), Montserrat Volcano Observatory www.mvo.ms <http://www.mvo.ms/> email: [email protected] <mailto:[email protected]>, [email protected] <mailto:[email protected]>, [email protected] <mailto:[email protected]> phone: (+1-664) 491-5647 fax: (+1-664) 491-2423 direct line: (+1-664) 491-5726 mobile: (+1-664) 495-0743 home: (+1-664) 491-3139 roaming: +44 7452 023889 trinidad: +1 (868) 780-4296 > On 15 Mar 2021, at 18:10, Ethan Merritt <[email protected]> wrote: > > On Monday, 15 March 2021 13:20:14 PDT Roderick Stewart wrote: >> I’m new to gnuplot (love it!) but can’t work out how to plot time series data from a file when the file contains no time information, just equally-spaced data values. >> >> I have a binary file which has one year’s worth of data at 1-minute intervals. >> >> I can plot it using: >> >> plot ‘2021.dat’ binary format=“%int32” using 0:1 >> >> But I want the X axis to be a date axis so I can, for example, set xrange. >> >> How do I get the timestamps into the plot? > > The units of time in gnuplot are seconds. > A date corresponds to the number of seconds elapsed since the start of the > epoch (1 Jan 1970). > > Each record in your data adds 60 seconds to the date. > So the task is > 1) Determine the canonical date (number of seconds since 1970) of the start time. > 2) Add 60 seconds for each data point > > Suppose your data starts with the first minute of 2021. > > timefmt = "%d-%b-%Y" > time0 = strptime( timefmt, "01-Jan-2021" ) > > # the xrange and tic placement will use the timefmt we just set > set xdata time > set xrange [time0 : *] > set xtics ("01-Jan-2021", "01-Feb-2021", "01-Mar-2021") > > # the actual tic labels will only use the month name > set xtics format "%b" # Only the month names > > plot '2021.dat' binary format=%int32" using (time0 + $0 * 60.) : 1 with lines > > > Ethan > > >> >> Thanks in advance. >> Roderick Stewart > > > _______________________________________________ gnuplot-info mailing list [email protected] Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info