Boxplot date formatting

2009/9/3 Dave Draper <ddraper@...2766...>:
Scott,

Have you done any plots using boxplot?

I am having an issue with the xaxis and trying to change the Date Formatter…

Thanks,

David

Hi David,

Please post questions to the mailing list, if you can clarify what
issues you are having (with a stand alone example) then I'm sure
you'll get help.

I guess you can specify the labels directly using something like:

import matplotlib.pyplot as plt
from matplotlib.dates import date2num

# dates is a sequence of datetime.datetime objects
# x is as per boxplot docstring

fig = plt.figure()
ax = fig.add_subplot(111)
ax.boxplot(x, positions=date2num(dates))

xlabels =
for dt in dates:
    xlabels.append(dt.strftime('%Y/%m/%d/%H:00'))

ax.xaxis.set_ticklabels(xlabels)

If you want to use date formatters it looks like you might need to add
a second axis using twinx. Perhaps there is a better way?

Cheers,
Scott