In reference to this post: I have been attempting to run the following code for plotting and live updating a graph. However, I am welcomed by the following error every time I attempt to run the function: AttributeError: 'list' object has no attribute 'set_xdata'
The rest of the function looks like the following:
def getData(self):
self.data = random.gauss(10,0.1)
self.ValueTotal.append(self.data)
#With value total being a list instantiated as ValueTotal = []
self.updateData()
def updateData(self):
if not hasattr(self, 'line'):
# this should only be executed on the first call to updateData
self.widget.canvas.ax.clear()
self.widget.canvas.ax.hold(True)
self.line = self.widget.canvas.ax.plot(self.ValueTotal,'r-')
self.widget.canvas.ax.grid()
else:
# now we only modify the plotted line
self.line.set_xdata(np.arange(len(self.ValueTotal)))
self.line.set_ydata(self.ValueTotal)
self.widget.canvas.draw()
While this code originated from sebastian and Jake French I have not had any success implementing this.Is there something I am doing wrong? What generates this error and how can I fix?
This is used strictly for an example and will not be copied into my code. I am simply using it for referential material and felt this would be the simplest way to communicate my problems with the community. I take no credit for the previous code.