You are reading an old version of the documentation (v3.1.3). For the latest version see
Version 3.1.3
Fork me on GitHub

Related Topics

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.

import matplotlib.pyplot as plt
import numpy as np

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

fig, ax = plt.subplots()

for i in range(len(data)):
    ax.set_title("frame {}".format(i))
    # Note that using time.sleep does *not* work here!

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

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery