Skip to content

Commit 55ba992

Browse files
committed
Merge pull request #5740 from jenshnielsen/animinitfix
Call init draw when restarting and saving the animation.
2 parents b65d2c4 + f4e52df commit 55ba992

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/animation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,7 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
778778
with writer.saving(self._fig, filename, dpi):
779779
for anim in all_anim:
780780
# Clear the initial frame
781-
if anim._init_func:
782-
anim._init_draw()
781+
anim._init_draw()
783782
for data in zip(*[a.new_saved_frame_seq()
784783
for a in all_anim]):
785784
for anim, d in zip(all_anim, data):
@@ -998,6 +997,7 @@ def _step(self, *args):
998997
# back.
999998
still_going = Animation._step(self, *args)
1000999
if not still_going and self.repeat:
1000+
self._init_draw()
10011001
self.frame_seq = self.new_frame_seq()
10021002
if self._repeat_delay:
10031003
self.event_source.remove_callback(self._step)
@@ -1168,11 +1168,13 @@ def _init_draw(self):
11681168
# artists.
11691169
if self._init_func is None:
11701170
self._draw_frame(next(self.new_frame_seq()))
1171+
11711172
else:
11721173
self._drawn_artists = self._init_func()
11731174
if self._blit:
11741175
for a in self._drawn_artists:
11751176
a.set_animated(self._blit)
1177+
self._save_seq = []
11761178

11771179
def _draw_frame(self, framedata):
11781180
# Save the data for potential saving of movies.

0 commit comments

Comments
 (0)