[SciPy-user] time series plotting (slightly off topic)

Pierre GM pgmdevlist at gmail.com
Tue Jan 2 14:11:58 CST 2007

> Thanks. Happy new year to you too. Hope you found some time to relax during
> the holiday season too! I'll take a look at your changes.

Oh I did, no worry :)

> My first attempt at plotting the time series objects was similar to this,
> but I found getting intelligent labels quite tricky. My new plotting code
> basically bypasses the built-in matplotlib date axis labelling and outputs
> the labels from scratch using my own logic...

I see. So, what about that:
- we transform your class so that it is a real subclass of mpl.axes or better, 
mpl.subplot (which means that we can use it a figure with other plots, and 
have access to all the basic methods)
- we write a proper DateFormatter to handle the dates, that would implement 
your labelling in a mpl friendly way. We wouldn't even add to go through the 
conversion to ordinals: just stick to the corresponding integers, and use the 
frequency to decide what to do, just like you did.

> The name of the function (dateOf) probably isn't entirely intuitive either. 

Yeah, I've noticed. The 'asfreq' method sounds more natural.

> As you are aware, weekly is one of those tricky frequencies that isn't a
> nice subset of the other frequencies. It's not a data frequency I use very
> often, but we'll probably need to discuss some strategy for converting it
> to other frequencies since it is an odd-ball case. ...

As you've noticed, I went to the easiest: a week is an isoweek, starting on 
Mondays (or whatever the convention in mx.DateTime is to process weeks).
Adding a different first day of the week might be an idea to consider, but I 
wouldn't rush on that...

> Also, looking at your code for the weekly frequency in tsdate... I think it
> might be a good idea to add an additional parameter to the __init__ method
> called "period" so you could specify a date with just the year and period
> (15th week for example, or maybe -1 for last period in year, etc).

That's an idea as well. But if we are to deal with other frequencies, I'd like 
to implement seasons, one season being a particular group of months. I don't 
think C would be needed, just using months should do the trick...

BTW, I just updated tseries.py and the corresponding test to handle 
pickling/unpickling. That works well on 1D data, I'll work on nD data later 

More information about the SciPy-user mailing list