-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Milestone
Description
Bug report
Bug summary
When using matplotlib.animation.FuncAnimation with a generator and without specifying save_count, a default value of save_count=100 is used. Instead, the generator should be run until it raises a StopIteration exception.
Code for reproduction
import numpy as np
from matplotlib.animation import FuncAnimation
def get_frames():
t = 0.0
x = np.linspace(0, 2*np.pi, 100)
l, = plt.plot(x, np.sin(x+t))
txt = plt.title("")
yield l, # Initial frame... not stored
for nt, t in enumerate(np.linspace(0,2*np.pi, 200)):
l.set_data(x, np.sin(x+t))
txt.set_text("frame: {}".format(nt))
yield l,
anim = FuncAnimation(plt.gcf(), lambda artists:artists, frames=get_frames())
# To view, use a notebook for example
from IPython.display import HTML
HTML(anim.to_html5_video())Actual outcome
Only frames 0 to 99 are drawn even though the generator will produce 200 frames (up to 199).
Expected outcome
An animation that runs until the generator raises StopIteration.
Matplotlib version
It looks like this will affect the latest version on GitHub. I tested this with version 1.5.3 from anaconda.