You are reading an old version of the documentation (v2.1.2). For the latest version see
Version 2.1.2
Fork me on GitHub


This Page

Random dataΒΆ

An animation of random data.

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

# Fixing random state for reproducibility

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)

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

Gallery generated by Sphinx-Gallery