Skip to content

Commit 682480c

Browse files
authored
Merge pull request matplotlib#16846 from anntzer/animnoman
Disconnect manager when resizing figure for animation saving.
2 parents 49baa91 + 44f5bb4 commit 682480c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/matplotlib/animation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,10 @@ def finish(self):
361361
def grab_frame(self, **savefig_kwargs):
362362
# docstring inherited
363363
_log.debug('MovieWriter.grab_frame: Grabbing frame.')
364-
# re-adjust the figure size in case it has been changed by the
365-
# user. We must ensure that every frame is the same size or
366-
# the movie will not save correctly.
364+
# Readjust the figure size in case it has been changed by the user.
365+
# All frames must have the same size to save the movie correctly.
367366
self.fig.set_size_inches(self._w, self._h)
368-
# Tell the figure to save its data to the sink, using the
369-
# frame format and dpi.
367+
# Save the figure data to the sink, using the frame format and dpi.
370368
self.fig.savefig(self._frame_sink(), format=self.frame_format,
371369
dpi=self.dpi, **savefig_kwargs)
372370

@@ -1113,10 +1111,12 @@ def func(current_frame: int, total_frames: int) -> Any
11131111
"frame size to vary, which is inappropriate for "
11141112
"animation.")
11151113
# canvas._is_saving = True makes the draw_event animation-starting
1116-
# callback a no-op.
1114+
# callback a no-op; canvas.manager = None prevents resizing the GUI
1115+
# widget (both are likewise done in savefig()).
11171116
with mpl.rc_context({'savefig.bbox': None}), \
11181117
writer.saving(self._fig, filename, dpi), \
1119-
cbook._setattr_cm(self._fig.canvas, _is_saving=True):
1118+
cbook._setattr_cm(self._fig.canvas,
1119+
_is_saving=True, manager=None):
11201120
for anim in all_anim:
11211121
anim._init_draw() # Clear the initial frame
11221122
frame_number = 0

0 commit comments

Comments
 (0)