# initialization function: plot the background of each framedefinit():line1.set_data([],[])line2.set_data([],[])return(line1,line2)
In [4]:
# animation function. This is called sequentially# i is the number of the frame, which leads to one full "circle"defanimate(i):x=np.linspace(0,2,1000)y1=np.sin(2*np.pi*(x-0.02*i))y2=np.cos(2*np.pi*(x-0.02*i))line1.set_data(x,y1)line2.set_data(x,y2)return(line1,line2)
In [5]:
# call the animator. blit=True means only re-draw the parts that have changed.anim=animation.FuncAnimation(fig,animate,init_func=init,frames=50,interval=40,blit=True)
In [6]:
anim
In [7]:
# this doesn't need this rc('animation', html='html5') parameter settingHTML(anim.to_html5_video())