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

Commitc92e48b

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 commitc92e48b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎lib/matplotlib/backend_bases.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,7 @@ def __init__(self, figure):
17721772
self._is_saving=False
17731773
figure.set_canvas(self)
17741774
self.figure=figure
1775+
self.manager=None
17751776
# a dictionary from event name to a dictionary that maps cid->func
17761777
self.callbacks=cbook.CallbackRegistry()
17771778
self.widgetlock=widgets.LockDraw()
@@ -2149,6 +2150,15 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
21492150
21502151
"""
21512152
self._is_saving=True
2153+
# Remove the figure manager, if any, to avoid resizing the GUI widget.
2154+
# Having *no* manager and a *None* manager are currently different (see
2155+
# Figure.show); should probably be normalized to None at some point.
2156+
_no_manager=object()
2157+
ifhasattr(self,'manager'):
2158+
manager=self.manager
2159+
delself.manager
2160+
else:
2161+
manager=_no_manager
21522162

21532163
ifformatisNone:
21542164
# get format from filename, or from backend's default filetype
@@ -2267,8 +2277,9 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
22672277
self.figure.set_facecolor(origfacecolor)
22682278
self.figure.set_edgecolor(origedgecolor)
22692279
self.figure.set_canvas(self)
2280+
ifmanagerisnot_no_manager:
2281+
self.manager=manager
22702282
self._is_saving=False
2271-
#self.figure.canvas.draw() ## seems superfluous
22722283
returnresult
22732284

22742285
@classmethod

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp