pyplot animation#

Generating an animation by calling pause between plotting commands.

The method shown here is only suitable for simple, low-performance use. For more demanding applications, look at the animation module and the examples that use it.

Note that calling time.sleep instead of pause would not work.

Output generated via matplotlib.animation.Animation.to_jshtml.

frame 49
import matplotlib.pyplot as plt
import numpy as np

data = np.random.random((50, 50, 50))

fig, ax = plt.subplots()

for i, img in enumerate(data):
    ax.set_title(f"frame {i}")
    # Note that using time.sleep does *not* work here!

Total running time of the script: ( 0 minutes 7.524 seconds)

Gallery generated by Sphinx-Gallery