Hi All,
I'm trying to plot a bar chart something like:
from pylab import *
from datetime import datetime,timedelta
now = datetime.now()
data1 = [1,2,3]
data2 = [4,5,6]
labels = [now-timedelta(1),now,now+timedelta(1)]
bar(labels,data1)
show()
However, this blows up:
Traceback (most recent call last):
bar(labels,data1)
File "matplotlib\pyplot.py", line 1402, in bar
ret = gca().bar(*args, **kwargs)
File "matplotlib\axes.py", line 3294, in bar
self.add_patch(r)
File "matplotlib\axes.py", line 1146, in add_patch
self._update_patch_limits(p)
File "matplotlib\axes.py", line 1152, in _update_patch_limits
xys = self._get_verts_in_data_coords(
File "matplotlib\patches.py", line 362, in get_verts
right = self.convert_xunits(x + self.width)
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'float'
What am I doing wrong?
Also, how do I go about adding a second set of bars? (ie: from data2)?
(Bear in mind that in the real use, there are over 600 days worth of data, so I want to take advantage of the normal tick locators, etc as much as possible...)
cheers,
Chris
···
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk