|
From: Craig D. <def...@bo...> - 2021-03-15 22:14:56
|
Careful with long intervals and seconds-counting. UNIX time, somewhat notoriously, is a transfer standard only! It follows UTC but ignores leap seconds, so after every leap second times in the past shift by one second. So the current UNIX epoch occurred on 1970-01-01 12:00:27 UTC, and in another couple of years it will have occurred later.
> On Mar 15, 2021, at 4:10 PM, Ethan Merritt <eam...@gm...> 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
> gnu...@li...
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>
|