dateformatter doesn't

Greetings. I've been having lots of luck with my date

    > plots. But I've been having a problem getting the
    > dateformatter to work. I'm using the code below. The dates
    > keep getting formatted with the default, "Sep 28 2006"
    > instead of what I want, "Sep 28"

This is an order of opertations problem. The call to "plot_date" sets
the DateFormatter, overriding your choices. You need to set your
custom formatter after the call to plot_date:

     ax.plot_date(dates, vals, 'bo')
     ax.xaxis.set_major_formatter(DateFormatter('%b %d'))
     ax.yaxis.set_major_formatter(FormatStrFormatter('%3.0f KBps'))

This is an annoyance that we can fix by setting the date formatter
only if the current formatter is *not* a date formatter instance.

JDH

    > Greetings. I've been having lots of luck with my date
    > plots. But I've been having a problem getting the
    > dateformatter to work. I'm using the code below. The dates
    > keep getting formatted with the default, "Sep 28 2006"
    > instead of what I want, "Sep 28"

This is an order of opertations problem. The call to "plot_date" sets
the DateFormatter, overriding your choices. You need to set your
custom formatter after the call to plot_date:

That's odd. I would think that it makes more sense to set the format *before* the data is plot, not after.

     ax.plot_date(dates, vals, 'bo')
     ax.xaxis.set_major_formatter(DateFormatter('%b %d'))
     ax.yaxis.set_major_formatter(FormatStrFormatter('%3.0f KBps'))

This is an annoyance that we can fix by setting the date formatter
only if the current formatter is *not* a date formatter instance.

Probably a good thing for people like me who have never used Matlab.

···

On Dec 16, 2006, at 10:25 PM, John Hunter wrote: