On Wed, Dec 1, 2010 at 12:28 AM, Ryan May <rmay31@gmail.com> wrote:
On Tue, Nov 30, 2010 at 7:00 PM, C M <cmpython@gmail.com> wrote:
> Thanks, Ryan.  I've done that now.  I use the OOP approach to matplotlib and
> embed it in wxPython, so my example uses that.  I did not know how to apply
> an AutoDateFormatter to an axis if using pylab and figured the basics of
> what I am trying to do are apparent from this sample.
>
> The sample is attached.  The point of it is that, despite it apparently
> using my AutoDateFormatter, all the dates at all levels of zoom are %Y (e.g.
> "2010").  This is because in the AutoDateFormatter subclass, the line:
>
> scale = float( self._locator._get_unit() )
>
> is *always* returning 365.0.
>
> I am not bothering for now to include the business about how point-picking
> remedies my problem, because the AutoDateFormatter shouldn't need
> that--obviously, the way I am doing it is wrong, and I'd like to know what
> it is.

I'm guessing your problem was that only the year was being shown,
regardless? It would seem the problem stems from the fact that while
you give your formatter the AutoDateLocator, you never tell the axis
to use this. I got what I considered the correct behavior by adding
the following line at linen 84 in the script:

      self.subplot.xaxis.set_major_locator(adl)

Does adding that get you what you want?

Ryan


Yes, that was it!  So simple, but I've been confused about how locators and formatters work together--now it makes much more sense.  Thank you very much.

Che