From the course: Python Data Visualization: Create Impactful Visuals, Animations, and Dashboards by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

FuncAnimation

FuncAnimation

FuncAnimation is the main class we're going to be using to generate our animations. The first step is to instantiate the FuncAnimation object, and for this we have to provide several important parameters. First, fig, which is a handle on a figure that we can create using our usual techniques from Matplotlib, either with plt.figure or plt.subplots, etc. which is the function that will generate each of the frames. This function should take the frame number as an argument, as a way of knowing essentially where it is on the timeline of the animation to generate the appropriate frame, and it can take any other extra arguments that you want to provide and that you require for your animation. Frames is the total number of frames that should be generated. Interval is another argument that specifies how many milliseconds should be between frames. So this is essentially how fast the animation is progressing. We also have the option, and these are optional arguments, of including an initFunc. So…

Contents