10000 FIX: Handle stopped animation figure resize · matplotlib/matplotlib@c6b3e20 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6b3e20

Browse files
committed
FIX: Handle stopped animation figure resize
Disable all animated artists after the animation has stopped. Also remove the resize callback from the animation framework.
1 parent fd83d95 commit c6b3e20

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

lib/matplotlib/animation.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,14 +1397,26 @@ def _step(self, *args):
13971397
# delay and set the callback to one which will then set the interval
13981398
# back.
13991399
still_going = super()._step(*args)
1400-
if not still_going and self.repeat:
1401-
self._init_draw()
1402-
self.frame_seq = self.new_frame_seq()
1403-
self.event_source.interval = self._repeat_delay
1404-
return True
1405-
else:
1406-
self.event_source.interval = self._interval
1407-
return still_going
1400+
if not still_going:
1401+
if self.repeat:
1402+
# Restart the draw loop
1403+
self._init_draw()
1404+
self.frame_seq = self.new_frame_seq()
1405+
self.event_source.interval = self._repeat_delay
1406+
return True
1407+
else:
1408+
# We are done with the animation. Call pause to remove
1409+
# animated flags from artists that were using blitting
1410+
self.pause()
1411+
if self._blit:
1412+
# Remove the resize callback if we were blitting
1413+
self._fig.canvas.mpl_disconnect(self._resize_id)
1414+
self._fig.canvas.mpl_disconnect(self._close_id)
1415+
self.event_source = None
1416+
return False
1417+
1418+
self.event_source.interval = self._interval
1419+
return True
14081420

14091421

14101422
class ArtistAnimation(TimedAnimation):

0 commit comments

Comments
 (0)
0