Pyplot Animation Example Code Won't Animate
I'm trying to come up to speed on the animation functionality in pyplot. I've grabbed the example code given here: https://matplotlib.org/2.0.0/examples/animation/animate_decay.htm
Solution 1:
If you're using Spyder, you need to change your Matplotlib backend by going to the menu
Tools > Preferences > IPython console > Graphics
and then selecting Automatic
in the section called Graphics backend
. After that, you need to restart Spyder or the kernel associated with the console you want this change to take effect on.
Solution 2:
A jupyter notebook would probably use the inline backend by default which cannot be animated (since it produces png images).
You may use the notebook backend to have the plot produced in an interactive notebook cell,
%matplotlib notebook
or the Tk backend to get a new window with the animation popping up,
%matplotlib tk
If using matplotlib 2.1, you may also use the %matplotlib inline
backend and show the animation as JavaScript,
from IPython.display import HTMLHTML(ani.to_jshtml())
Post a Comment for "Pyplot Animation Example Code Won't Animate"