Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Disconnect manager when resizing figure for animation saving. #16846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down