Skip to content

Commit 6f674d5

Browse files
committed
Make sure that animations are probably cleared before rerunning by calling init both when showing and saving
1 parent 561ce23 commit 6f674d5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/animation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ def _start(self, *args):
611611
# actually start the event_source. We also disconnect _start
612612
# from the draw_events
613613
self.event_source.add_callback(self._step)
614+
self._init_draw()
614615
self.event_source.start()
615616
self._fig.canvas.mpl_disconnect(self._first_draw_id)
616617
self._first_draw_id = None # So we can check on save
@@ -760,6 +761,9 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
760761
# since GUI widgets are gone. Either need to remove extra code to
761762
# allow for this non-existant use case or find a way to make it work.
762763
with writer.saving(self._fig, filename, dpi):
764+
for anim in all_anim:
765+
# Clear the initial frame
766+
anim._init_draw()
763767
for data in zip(*[a.new_saved_frame_seq()
764768
for a in all_anim]):
765769
for anim, d in zip(all_anim, data):

0 commit comments

Comments
 (0)