diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 7ff2dd36b5bb..c9d7c03478a3 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -361,12 +361,10 @@ def finish(self): def grab_frame(self, **savefig_kwargs): # docstring inherited _log.debug('MovieWriter.grab_frame: Grabbing frame.') - # re-adjust the figure size in case it has been changed by the - # user. We must ensure that every frame is the same size or - # the movie will not save correctly. + # Readjust the figure size in case it has been changed by the user. + # All frames must have the same size to save the movie correctly. self.fig.set_size_inches(self._w, self._h) - # Tell the figure to save its data to the sink, using the - # frame format and dpi. + # Save the figure data to the sink, using the frame format and dpi. self.fig.savefig(self._frame_sink(), format=self.frame_format, dpi=self.dpi, **savefig_kwargs) @@ -1113,10 +1111,12 @@ def func(current_frame: int, total_frames: int) -> Any "frame size to vary, which is inappropriate for " "animation.") # canvas._is_saving = True makes the draw_event animation-starting - # callback a no-op. + # callback a no-op; canvas.manager = None prevents resizing the GUI + # widget (both are likewise done in savefig()). with mpl.rc_context({'savefig.bbox': None}), \ writer.saving(self._fig, filename, dpi), \ - cbook._setattr_cm(self._fig.canvas, _is_saving=True): + cbook._setattr_cm(self._fig.canvas, + _is_saving=True, manager=None): for anim in all_anim: anim._init_draw() # Clear the initial frame frame_number = 0