Matplotlib animation. I understand that Pythonista doesn't support the matplotlib animation APIs. Are there any work-arounds?
I have an IOT application where measurement data is multicast from the IOT device and received by my iPAD for graphing. I wish to build a simple "strip chart" plot that updates each time new data is received.
I can create a new plot with plt.show( ) each time but my console eventually is overloaded with a series of plot figures. How can I update an existing plot and have it rendered right away?
Unfortunately the fig.canvas.flush_events( ) API is not implemented in Pythonista. That's what I use on my desktop.
Here's a simple example that works great on the desktop. What modifications are needed to get this to work in Pythonista? The fig.canvas.flush_events() is a problem on Pythonista.
import numpy as np import time import matplotlib.pyplot as plt plt.ion() fig = plt.figure() tstart = time.time() # for profiling x = np.arange(0,2*np.pi,0.01) # x-array line, = plt.plot(x,np.sin(x)) for i in np.arange(1,200): line.set_ydata(np.sin(x+i/10.0)) # update the data plt.draw() fig.canvas.flush_events() plt.pause(0.001) #redraw figure, allow GUI to handle events print ('FPS:' , 200/(time.time()-tstart)) plt.ioff() plt.show() ```