|
From: Virgil S. <vs...@it...> - 2015-04-23 10:44:15
|
The following interesting example (random_data.py) is posted at: http://matplotlib.org/1.4.2/examples/animation/random_data.html 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): line.set_ydata(data) return line, def data_gen(): while True: yield np.random.rand(10) ani = animation.FuncAnimation(fig, update, data_gen, interval=100) plt.show() This codes works; but, I am very confused by it. For example: 1. There are 3 positional arguments given for animation.FuncAnimation; but, in the API documentation for this class (http://matplotlib.org/api/animation_api.html), only two positional arguments are shown. 2. data, the argument to the update function seems to be undefined. I would appreciate an explanation (in some detail) of how this code actually works. |