>>>>> "Simson" == Simson Garfinkel <[EMAIL PROTECTED]> writes:
    Simson> That's odd. I would think that it makes more sense to set
    Simson> the format *before* the data is plot, not after.
...
    Simson> Probably a good thing for people like me who have never
    Simson> used Matlab.

This is not a matlab vs non-matlab thing, it's just a plain-ol-bug.
As far as I know, matlab doesn't have a concept of tick locators and
formatters, it's an idea loosely borrowed from pyx.  The order of
operations bug crept in because matplotlib has a default tick locator
and formatter that are not appropriate for date plotting, and when you
call ax.plot_date, which just forwards the call on to ax.xaxis_date,
the tick locator and formatter were being forcibly reset to the
AutoDateLocator and AutoDateFormatter.  If you are a naive user and
have done no customization, 99% of the time this is what you want. But
if you have set your DateFormatter or DateLocator already, then this
is not what you want.

I made a change will help: now I check and see of the
formatter/locator is of the right type before forcibly resetting, eg

    def xaxis_date(self, tz=None):
        #...snip
        thisformatter = self.xaxis.get_major_formatter()
        if not isinstance(thisformatter, DateFormatter):
            formatter = AutoDateFormatter(locator)
            self.xaxis.set_major_formatter(formatter)

This will help, and should address your use case, but it is not a complete
solution because it doesn't cover the use-case where the user may have
supplied a custom date formatter not derived from DateFormatter.  We'd
rather use duck-typing here rather than isinstance but there is no
clear way to do this. We might be able to manage this by checking for
explicit user calls to set_major_formatter and friends but this is
probably brittle.  To address this (rare) use case, I've
modified the Axes.plot_date docstring:

        Note if you are using, custom date tickers and formatters, it
        may be necessary to set the formatters/locators after the call
        to plot_date

Changes in svn.

JDH




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to