You are reading an old version of the documentation (v1.5.3). For the latest version see

Matplotlib 2.0.0rc2 is available

Install the release candidate now!



This Page

animation example code: random_data.pyΒΆ

[source code]

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig, ax = plt.subplots()
line, = ax.plot(np.random.rand(10))
ax.set_ylim(0, 1)

def update(data):
    return line,

def data_gen():
    while True:
        yield np.random.rand(10)

ani = animation.FuncAnimation(fig, update, data_gen, interval=100)

Keywords: python, matplotlib, pylab, example, codex (see Search examples)