> 3) I am getting just hammered with the following error *a lot* in date
> plotting lately:
>
> ValueError: ordinal must be >= 1


OK, I made up a small runnable sample to show this with bar().  (Using
code that someone else wrote[1]).  This code runs when using
plot_date(), but if you comment that out and comment in the ax.bar()
line, it will give this ValueError.


import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import datetime as dt

# Make a series of events 1 day apart
x = mpl.dates.drange(dt.datetime(2009,10,1),
                     dt.datetime(2010,1,15),
                     dt.timedelta(days=1))
# Vary the datetimes so that they occur at random times
# Remember, 1.0 is equivalent to 1 day in this case...
x += np.random.random(x.size)

# We can extract the time by using a modulo 1, and adding an arbitrary base date
times = x % 1 + int(x[0]) # (The int is so the y-axis starts at midnight...)

# I'm just plotting points here, but you could just as easily use a bar.
fig = plt.figure()
ax = fig.add_subplot(111)

#comment out:
ax.plot_date(x, times, 'ro')

#comment in
#ax.bar(x, times)

ax.yaxis_date()
fig.autofmt_xdate()

plt.show()


[1]http://stackoverflow.com/questions/4790265/plot-time-of-day-vs-date-in-matplotlib

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to