On Tue, Nov 30, 2010 at 10:44 AM, C M <cmpython@...> wrote:
>
>
> On Sun, Nov 28, 2010 at 8:52 PM, C M <cmpython@...> wrote:
>>
>> How can I correctly subclass AutoDateFormatter and use it in my code?
>>
>> What I am doing is copying the code from matplotlib's AutoDateFormatter
>> and changing the strings for how the dates are represented and making that a
>> class, MyAutoDateFormatter. AutoDateFormatter expects a locator, and I
>> think (?) the default is AutoDateLocator. So in my code I am doing this:
>>
>> adl = AutoDateLocator()
>> myformatter = MyAutoDateFormatter(adl)
>> axis.xaxis.set_major_formatter(myformatter)
>>
>> But when I run it, no matter the level of zoom, it says "2010" (when it
>> should change depending on zoom level).
>>
>> However, if I go into the matplotlib dates.py code itself and save the
>> same changes to the date strings there, and I comment out the above code,
>> then it works: the date strings change depending on level of zoom.
>
> I've also just noticed that if I use the above code after the lines have
> been plotted, but then I click on one of the points (which causes a
> point-picking routine that ultimately plots a highlighting marker over that
> point), the x axis suddenly changes to use MyAutoDateFormatter's format
> strings. (If I call it before I plot anything, it doesn't help, though).
>
> Is the act of plotting somehow "refreshing" things? What can I call in
> order to force this to happen without actually plotting any additional
> points after my lines are plotted?
It's difficult to tell without seeing the code that's producing the
problem. If you can boil your problem down to a simple, self-contained
script and post it here, then we can take a look and see what's going
on.
Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
|