Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Documentation Link
https://matplotlib.org/devdocs/gallery/animation/index.html
Problem
Figured it'd be useful to have at least one example in the docs to show that it's possible and encourage the use of the OO paradigm. There used to be asubplot example, butthat was back when it was overly complicated to do animated subplots. it was removed in#10125
Suggested improvement
Add a new example showing how animation on subplots work. I originally thought of merging existing examples but they all feel overly complicated so I think this should be super simple, like 3 plots: sine/cosine/tangent and two lines each in the style ofhttps://matplotlib.org/devdocs/gallery/animation/simple_anim.html#sphx-glr-gallery-animation-simple-anim-py
I was thinking something like this, but if there's an easier or alternative, we should probably show that (too/instead of):
importnumpyasnpimportmatplotlib.pyplotaspltimportmatplotlib.animationasanimationfig, (ax1,ax2,ax3)=plt.subplots()x=np.arange(0,2*np.pi,0.01)line1,=ax1.plot(x,np.sin(x))line2,=ax2.plot(x,np.cos(x))line3,=ax3.plot(x,np.tan(x))defanimate(i):line1.set_ydata(np.sin(x+i/50))# update the data.line2.set_ydata(np.sin(x+i/50))line3.set_ydata(np.sin(x+i/50))return [line1,line2,line3]ani=animation.FuncAnimation(fig,animate,interval=20,blit=True,save_count=50)