2D Animated Orbits

Learn how to plot 2D animated orbits.

We'll cover the following...

Now, let’s animate the orbit. Note that you have reset the argument of perigee to be 0 degrees.

Matplotlib’s FuncAnimation() takes a function and computes the next value given a range, plots the new value, waits a specified period of time, and then plots the next value. In your case, your animation is really just displaying the pre-computed X and Y coordinates of the orbit. You need to do some prep work to plot the orbit, plot the starting point of a red dot that will go around the orbit, and internally define an animate() function that accepts the incremental value i and returns (pos[i][1], pos[i][0]), so that the FuncAnimation() ...