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 nbagg
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
def 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 in 5c58ea9
FuncAnimation._init_draw()
is called, if no init_func
is given, the first frame sequence is appended to self._save_seq
. After which, matplotlib/lib/matplotlib/animation.py
Line 769 in 5c58ea9
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.