manpagez: man pages & more
info gnuplot
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.24 Time/Date data

‘gnuplot‘ supports the use of time and/or date information as input data. This feature is activated by the commands ‘set xdata time‘, ‘set ydata time‘, etc.

Internally all times and dates are converted to the number of seconds from the year 2000. The command timefmt defines the format for all inputs: data files, ranges, tics, label positions—in short, anything that accepts a data value must receive it in this format. Since only one input format can be in force at a given time, all time/date quantities being input at the same time must be presented in the same format. Thus if both x and y data in a file are time/date, they must be in the same format.

The conversion to and from seconds assumes Universal Time (which is the same as Greenwich Standard Time). There is no provision for changing the time zone or for daylight savings. If all your data refer to the same time zone (and are all either daylight or standard) you don’t need to worry about these things. But if the absolute time is crucial for your application, you’ll need to convert to UT yourself.

Commands like xrange will re-interpret the integer according to timefmt. If you change timefmt, and then ‘show‘ the quantity again, it will be displayed in the new timefmt. For that matter, if you give the deactivation command (like xdata), the quantity will be shown in its numerical form.

The commands ‘set format‘ or ‘set tics format‘ define the format that will be used for tic labels, whether or not the specified axis is time/date.

If time/date information is to be plotted from a file, the using option _must_ be used on the ‘plot‘ or ‘splot‘ command. These commands simply use white space to separate columns, but white space may be embedded within the time/date string. If you use tabs as a separator, some trial-and-error may be necessary to discover how your system treats them.

The ‘time‘ function can be used to get the current system time. This value can be converted to a date string with the strftime function, or it can be used in conjunction with timecolumn to generate relative time/date plots. The type of the argument determines what is returned. If the argument is an integer, ‘time‘ returns the current time as an integer, in seconds from 1 Jan 2000. If the argument is real (or complex), the result is real as well. The precision of the fractional (sub-second) part depends on your operating system. If the argument is a string, it is assumed to be a format string, and it is passed to strftime to provide a formatted time/date string.

The following example demonstrates time/date plotting.

Suppose the file "data" contains records like

      03/21/95 10:00  6.02e23

This file can be plotted by

      set xdata time
      set timefmt "%m/%d/%y"
      set xrange ["03/21/95":"03/22/95"]
      set format x "%m/%d"
      set timefmt "%m/%d/%y %H:%M"
      plot "data" using 1:3

which will produce xtic labels that look like "03/21".

See ‘time_specifiers‘.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 4, 2012 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.