Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

FuncAnimation w/o init_func breaks when saving #5399

Copy link
Copy link
Closed
@cbreeden

Description

@cbreeden
Issue body actions

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:

im 1

The animation displays correctly in the notebook. The issue is introduced here

for anim in all_anim:
. When FuncAnimation._init_draw() is called, if no init_func is given, the first frame sequence is appended to self._save_seq. After which,
for data in zip(*[a.new_saved_frame_seq()
is executed and 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.