Save Matplotlib Animations as GIFs Saving animations in Matplotlib requires very little additional code. In fact, all you have to do is add a single line of code to your program to save your animations as a GIF.
matplotlib.animation.FuncAnimation(fig, func, frames=None, init_func=None, fargs=None, save_count=None, *, cache_frame_data=True, **kwargs) 程式碼: import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation x = [] y = [] figure, ax = plt.subplo...
Useanimation installas globle variable. Sample import numpy as np import matplotlib.pyplot as plt from matplotlib import animation, rc from IPython.display import HTML class testAnimation: def __init__(self): # First set up the figure, the axis, and the plot element we want to animate self...
matplotlib.animation.FuncAnimation(fig,func,frames=None,init_func=None,fargs=None,save_count=None,*,cache_frame_data=True,**kwargs) Código: importnumpyasnpimportmatplotlib.pyplotaspltfrommatplotlib.animationimportFuncAnimation x=[]y=[]figure,ax=plt.subplots(figsize=(4,3))(line,)=ax.plot(x,y...