plotting data against a time axis

Paul McGuire ptmcg at austin.rr.com
Sat Nov 15 21:58:17 EST 2003


"Dennis Lee Bieber" <wlfraed at ix.netcom.com> wrote in message
news:a6ui81-705.ln1 at beastie.ix.netcom.com...
>         Maybe I need to check the specs of the DateTime module, but most
> systems that work in dates usually store them internally in a linear
> format. Ignoring the /time/ aspect, a date could be stored in pseudo
> human readable format as an 8-digit integer -- yyyymmdd -- which sorts
> linearly, regardless of how it is formatted for display.

Ooops, not really.  This trick will correctly *order* dates for sorting, but
they wont ascend linearly.  I think that you'll find big non-linear gaps
between the last days of a month and the first day of the next:
20031029
20031030 (delta is 1)
20031031 (delta is 1)
20031101 (delta is 70)
...
20031230
20031231 (delta is 1)
20040101 (delta is 8870!)


>         At worst, take the earliest (time wise) date in your data as an
epoch,
> and rebuild your dictionary using the delta from the epoch as the new
> key/index.
For the OP to get a nice scatter-plot, with linear time as the x-axis
variable, this is what he/she will have to do.  Simplest is to contrive an
epoch with a starting day number (01/01/2000?), plus the time represented as
a fraction of a whole day, (so that noon on day 17 will be represented as
17.5, 6pm as 17.75, etc.)






More information about the Python-list mailing list