Open yanglipmed opened 6 years ago
Hi, I suppose matplotlib in Pythonista is little different and modified compared to computer version, due to iOS peculiarities (don't forget matplotlib is not pure python, so when compiled and built for ios by omz maybe has suffered of some (indispensable) modifications to run on ios). About your code, try to add import time, import matplotlib.pyplot as plt, and add plt. before plot(a) and show().
That is:
import console, time
import numpy as np
import matplotlib.pyplot as plt
a=np.array([])
for i in range(20):
a=np.append(a,np.random.randn(10))
plt.plot(a)
plt.show()
time.sleep(0.2)
console.clear()
the nice thing would be to create a code that instead of deleting the entire graph to replace it with the updated one, leaves everything unchanged except the actual curve that is updated with a certain frequency and the x-y axes that could increase or decrease their scale, in this way the refresh would be more eyes relaxing. Bye
Thanks
Hi, I am trying to make animation with FuncAnimation in matplotlib.animation. The same codes that work well on my PC don't work in Pythonista. Is this a problem of Pythonista?
I also tried to do consecutive plotting on the same figure to mimic an animation. Although I used hold('off') or ax.plot(), Pythonista still make a lot of figures, not plot on the same figure. console.clear() doesn't work neither, as it yields a short time when no figure one the screen between two consecutive plotting.
Here are simple test codes:
import console import numpy as np from pylab import *
a=np.array([]) for i in range(20): a=np.append(a,np.random.randn(10)) plot(a) show(a) time.sleep(0.2) console.clear()