Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
I was trying to work out a patch to#5335 and ran into issues introduced in merge#4800. The following code is slightly simplified example from the animations examples:
%matplotlib nbaggimport matplotlibimport matplotlib.pyplot as pltimport matplotlib.animation as animationimport numpy as npdef update_line(num, data, line): line.set_data(data[...,:num]) return line,fig = plt.figure()plt.xlim(0, 1)plt.ylim(0, 1)data = np.random.rand(2, 10)l, = plt.plot([], [], 'r-')ani = animation.FuncAnimation(fig, update_line, 10, fargs=(data, l), interval=50, blit=True)ani.save('im.gif', writer='imagemagick')
running this yields:
The animation displays correctly in the notebook. The issue is introduced here
matplotlib/lib/matplotlib/animation.py
Line 766 in5c58ea9
foraniminall_anim: |
FuncAnimation._init_draw()
is called, if noinit_func
is given, the first frame sequence is appended toself._save_seq
. After which,matplotlib/lib/matplotlib/animation.py
Line 769 in5c58ea9
fordatainzip(*[a.new_saved_frame_seq() |
FuncAnimation.new_saved_seq()
then only returns the first drawn frame for which to iterate over. The end result is an animation file with only one frame.