I am trying to set up an animation to display some data taken over a GPIB interface in real time. This I can get to work fine as long as I use a line, i.e. matplotlib's plot() function.
However, as I am taking discrete data points, I want to use the scatter() function. This presents me with the following error: "set_array() takes exactly 2 arguments (3 given)"
The error is manifest in the 2 locations shown in the code below.
def intitalisation():
realtime_data.set_array([0],[0]) ******ERROR HERE*******
return realtime_data,
def update(current_x_data,new_xdata,current_y_data, new_ydata):#
current_x_data = numpy.append(current_x_data, new_xdata)
current_y_data = numpy.append(current_y_data, new_ydata)
realtime_data.set_array( current_x_data , current_y_data ) ******ERROR HERE*******
def animate(i,current_x_data,current_y_data):
update(current_x_data,new_time,current_y_data,averaged_voltage)
return realtime_data,
animation = animation.FuncAnimation(figure, animate, init_func=intitalisation, frames = number_of_measurements, interval=time_between_measurements*60*1000, blit=False, fargs= (current_x_data,current_y_data))
figure = matplotlib.pyplot.figure()
axes = matplotlib.pyplot.axes()
realtime_data = matplotlib.pyplot.scatter([],[])
matplotlib.pyplot.show()
So my question to you all is, why does set_array() believe that I am passing 3 arguments to it? I do not understand, as I can only see 2 arguments. And how can I correct this error?
EDIT: I should note that the code shown is not complete, just the part which has the error, with other parts deleted for clarity.