Here is the explanation for the preceding code blocks:
- ani = FuncAnimation(fig, animate, 1000, init_func=init, blit=True, interval=2, save_count=50, repeat=False, repeat_delay=1000) activates the animation. Since we need to maintain the state of the object, we must assign it to a variable, as we have done here: ani. This also helps in saving the animation to an .mp4 file, which we will learn how to do in the next recipe:
- fig is the figure that is being animated.
- animate is the function that directs the way the animation is applied to the plot:
- i is the system variable, containing the frame number of the current frame being processed.
- We are keeping the x axis data constant, but changing the y axis data as a function of ...