November 2018
Beginner to intermediate
214 pages
5h 2m
English
Finally, to write these animations instead of having them displayed in the Jupyter Notebook, we need to produce a video or an animated GIF that we can put into a PowerPoint presentation or on a website. To do this, we simply take the return value of the animation and use the save method. Hence, by using anim.save, we can produce sine.mp4, which will take some time to render:
# Saving the animation as a mp4 videonums = np.arange(0,10,0.1)sin, = plt.plot(nums, np.sin(nums))frames=np.arange(0,2*np.pi,0.1)def update(i): sin.set_ydata(np.sin(nums+i))anim = FuncAnimation(plt.gcf(), update, frames=frames, interval=50)anim.save('sine.mp4')
Use the VLC player to play the video that we have produced ...
Read now
Unlock full access