I'm new to matplolib, and trying to update the data that a bar graph is displaying (the application needs to continually update temperature data, so we want to regularly update a given graph's data at some fixed rate). The examples show a way to update a line graph, created using the 'plot' command, but we can't use the same approach with bar graphs created with 'bar' - it doesn't appear to support a set_data() function.
The dynamic_demo_wx.py example contains the following to update the line graph:
def init_plot_data(self):
a = self.figmgr.add_subplot(111)
self.ind = numpy.arange(60)
tmp = []
for i in range(60):
tmp.append(numpy.sin((self.ind+i)*numpy.pi/15))
self.X = numpy.array(tmp)
self.lines = a.plot(self.X[:,0],'o')
self.count = 0
def onTimer(self, evt):
self.count += 1
if self.count > 99: self.count = 0
self.lines[0].set_data(self.ind, self.X[:,self.count])
self.canvas.draw()
self.canvas.gui_repaint()
But creating a bar graph with "bar" instead of "plot" like
self.bar = self.a.bar(self.ind, self.data, width, color='r')
produces the following
Traceback (most recent call last):
File "dynamic_demo_wx.py", line 108, in onTimer
self.bar[1].set_data(self.ind,self.data)
AttributeError: Rectangle instance has no attribute 'set_data'
Can anyone help? I've pored over the onilne docs, and tried various changes, to no affect.
TIA