animation_test


animation_test, a Python code which computes a sequence of solutions to a partial differential equation, using matplotlib, displaying each solution to the screen WITHOUT requiring the user to hit RETURN to see the next image.

matplotlib provides a procedure FuncAnimation() for creating animations. However, this procedure has limited documentation, and a peculiarly constrained user interface. The user provides a ``frame(i)'' function whose only input is the frame counter i, which must return, in a somewhat obscure fashion, the raw plot elements involved in the frame.

While it's not too hard to use this facility to create an animation of a sine curve, it's more difficult to see how to, for instance, compute a sequence of solutions to a partial differential equation, and display the sequence of time solutions in a movie file. One difficulty is that this calculation requires the frame function to have access to the data at the previous time step, which can't be done through the parameter list, and which isn't easily done simply by declaring the data in the user's main program. This code demonstrates one way of computing scientifically interesting results and watching as they are computed.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

animation_test is available in a Python version.

Related Data and Programs:

allen_cahn_pde, a Python code which sets up and solves the 1D Allen-Cahn reaction-diffusion partial differential equation (ODE).

graphics_test, Python codes which illustrate how various kinds of data can be displayed and analyzed graphically.

movie_test, a Python code which creates a movie file from a sequence of solutions to a partial differential equation, using matplotlib.

Source Code:


Last revised on 10 July 2020.