I have calculated some results and they are in the form of 64x64 arrays. Each array is created some time after the other. I want to show these arrays one after the other, like an animation. I have tried many ways, and got none to work. Im am quite frustrated and the questions on SO regarding animations have not been able to help me get this to work. This is not the first time I try this, every time my result is the same though: I have never gotten this to work.
The approaches I have tried:
The current code I have:
fig, ax = plt.subplots()
def animate(i):
return imagelist[i]
def init():
fig.set_data([],[])
return fig
ani = animation.FuncAnimation(fig, animate, np.arange(0, 19), init_func=init,
interval=20, blit=True)
plt.show()
Here imagelist is a list of the arrays I mention above (length 20, 0 through 19). My question is how can I get this to work?
Are you running in an interactive python session in Spyder? If so, you may need to run
To make sure that the animation opens in its own window, rather than being displayed inline (it doesn't work inline).
Also, make sure that you are not falling for the calling animation.FuncAnimation inside a function issue
I implemented a handy script that just suits your need. Try it out here
For your example:
Copying almost exactly from your first link (and adding some comments):
This animates as I expect