On Tue, Jul 21, 2009 at 8:00 PM, Nick Seow<nicks...@gmail.com> wrote:
> Hi,
>
> I'm worried that I'm doing something stupid, but can't quite spot it.
>
> testBarCharts() :- X axis in integers. Works fine.
> testBarChartsDTMonths() :- X axis in datetimes, 1 month between data
> points. Works fine
> testBarChartsDTHours() :- X axis in datetimes, 1 hour between data

under the hood, mpl converts datetime objects to days since 1/1/0000,
using a floating point representation for fractions of a day.  So a
bar width or 1.0 corresponds to 1 day.  The default width to the bar
command is 0.8, which is too thin for months, just right for days, and
too wide for hours.  Eg, for hours do

  bar(x, y, width=0.8*1/24.)  # width is 0.8 hours

for months, do something like

  bar(x, y, width=0.8*30/24.)  # width approx 80% of a month

Perhaps bar should take a width=None arg and try to infer the ideal
with, eg assuming even spacing, but for now you need to specify the
width in fractional days when making bar plots with datetimes.

JDH

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to