Alan W. Irwin wrote:
On 2007-11-22 19:18-0000 Andrew Ross wrote:

  
For some time I've been pondering ways of plotting up time series over
days / months. Many plotting packages (e.g. gnuplot) provide special
options for time series so you can format the axis labels in a human
dd/mm type format for example. Plplot currently has no such facility.
This has been brought up on the list before. It is also something I'd
personally find useful in my work.

What I am thinking about is adding a new (x|y)opt flag for plaxes, perhaps
'T'. This would interpret the corresponding axis as a time. The format
of the time would be determined using a new function, perhaps pltimefmt
which would allow you to specify the time format,
e.g. pltimefmt("%H:%d")
would format the labels as hour:minute. I would suggest adopting the
format used by strftime. This function is relatively standard (it is
in SVr4, C89 and C99) and would make a good basis for the formatting
routine.  Again, there is the question of how a time should be
represented. I would suggest interpreting the data as seconds since 1st
Jan 1970 (the usual standard).

Any comments?
    

I was interested enough so I googled for strftime.  strftime appears
to be a comprehensive time formatting routine that would be a good to
use.  There is even a "poor man's version" that you could use
from http://www.perlmonks.org/?node_id=290054.

Anyhow, I think you have a good idea.

  
Alternative representations of date and time could be Julian dates (effectively
the number of days, time as a fraction, since well before Christ). The advantage
of that is that the definition is platform-independent, which is not the case for
the number of seconds since "epoch" - ubiquitously but not universally chosen
to be midnight, 1 january 1970. Another advantage is that the valid range is
much larger than that for the number of seconds (if stored as a 32-bits
signed integer):
- Julian dates range from effectively the beginning of time to Armageddon, 
  as they are stored as double precision reals (resolution is slightly more
  than milliseconds, IIRC).
- The date/time as seconds since 1 january 1970 ranges from 1903 to 2037 (IIRC)

The drawback is that you will have to write more code (I am not aware of
strftime()-equivalent for Julian date/time, but there might be). And perhaps
the API will be more involved - dealing with the Gregorian calendar
more explicitly. But there are good algorithms to do these conversions.

Still, having a date/time type axis will be a good thing! It will enable us
to implement a number of "financial" plot types, for instance (see a question
on the list from may/june this year).

Regards,

Arjen