Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6b34d4

Browse files
committed
Unset the canvas manager when saving the figure.
Saving a figure may involve temporarily resizing the canvas (e.g. due todifferent dpi), but we don't want that resize to be propagated to theactual GUI widget. Ensure this by temporarily unsetting the manager aswell.
1 parent4753f6c commita6b34d4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎lib/matplotlib/backend_bases.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,15 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
21492149
21502150
"""
21512151
self._is_saving=True
2152+
# Remove the figure manager, if any, to avoid resizing the GUI widget.
2153+
# Having *no* manager and a *None* manager are currently different (see
2154+
# Figure.show); should probably be normalized to None at some point.
2155+
_no_manager=object()
2156+
ifhasattr(self,'manager'):
2157+
manager=self.manager
2158+
delself.manager
2159+
else:
2160+
manager=_no_manager
21522161

21532162
ifformatisNone:
21542163
# get format from filename, or from backend's default filetype
@@ -2267,8 +2276,9 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
22672276
self.figure.set_facecolor(origfacecolor)
22682277
self.figure.set_edgecolor(origedgecolor)
22692278
self.figure.set_canvas(self)
2279+
ifmanagerisnot_no_manager:
2280+
self.manager=manager
22702281
self._is_saving=False
2271-
#self.figure.canvas.draw() ## seems superfluous
22722282
returnresult
22732283

22742284
@classmethod

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp