2012/11/22 Jeffrey Melloy jmel...@gmail.com:
I'm graphing data from a web service, and seem to have stumbled upon a
bug when dates are graphed without any values.
Here's a minimum repro:
import datetime
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
x = []
st = datetime.datetime(2012,11,21)
while st datetime.datetime(2012,11,21, 16, 00):
x.append(st)
st = st + datetime.timedelta(minutes=30)
y = [None] * len(x)
ax.plot(x,y)
fig.autofmt_xdate()
plt.show()
The stack trace I get:
Traceback (most recent call last):
File min_mpl.py, line 15, in module
fig.autofmt_xdate()
File c:\python26\lib\site-packages\matplotlib\figure.py, line 318,
in autofmt_xdate
for label in ax.get_xticklabels():
File c:\python26\lib\site-packages\matplotlib\axes.py, line 2507,
in get_xticklabels
self.xaxis.get_ticklabels(minor=minor))
File c:\python26\lib\site-packages\matplotlib\axis.py, line 1104,
in get_ticklabels
return self.get_majorticklabels()
File c:\python26\lib\site-packages\matplotlib\axis.py, line 1088,
in get_majorticklabels
ticks = self.get_major_ticks()
File c:\python26\lib\site-packages\matplotlib\axis.py, line 1186,
in get_major_ticks
numticks = len(self.get_major_locator()())
File c:\python26\lib\site-packages\matplotlib\dates.py, line 749,
in __call__
self.refresh()
File c:\python26\lib\site-packages\matplotlib\dates.py, line 758, in
refresh
dmin, dmax = self.viewlim_to_dt()
File c:\python26\lib\site-packages\matplotlib\dates.py, line 530,
in viewlim_to_dt
return num2date(vmin, self.tz), num2date(vmax, self.tz)
File c:\python26\lib\site-packages\matplotlib\dates.py, line 289,
in num2date
if not cbook.iterable(x): return _from_ordinalf(x, tz)
File c:\python26\lib\site-packages\matplotlib\dates.py, line 203,
in _from_ordinalf
dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be = 1
Adding a 0 the current date stops getting the exception, but the
range seems wildly messed up. (2011 - 2014).
I can't figure out what's going on here, the calls in the stack trace
seem unrelated to Y data.
As a quick and dirty workaround you can set the first and last Y
values to 0 --won't work well if you use markers.
Goyo
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users