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

Skip to content

Commit a7e3142

Browse files
authored
Merge pull request #26595 from meeseeksmachine/auto-backport-of-pr-26591-on-v3.8.x
Backport PR #26591 on branch v3.8.x (Fix ToolBase.figure property setter.)
2 parents 5276434 + e2c96a9 commit a7e3142

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/matplotlib/backend_tools.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,15 @@ def __init__(self, toolmanager, name):
118118
lambda self: self._figure.canvas if self._figure is not None else None,
119119
doc="The canvas of the figure affected by this tool, or None.")
120120

121-
@property
122-
def figure(self):
123-
"""The Figure affected by this tool, or None."""
124-
return self._figure
125-
126-
@figure.setter
127-
def figure(self, figure):
121+
def set_figure(self, figure):
128122
self._figure = figure
129123

130-
set_figure = figure.fset
124+
figure = property(
125+
lambda self: self._figure,
126+
# The setter must explicitly call self.set_figure so that subclasses can
127+
# meaningfully override it.
128+
lambda self, figure: self.set_figure(figure),
129+
doc="The Figure affected by this tool, or None.")
131130

132131
def _make_classic_style_pseudo_toolbar(self):
133132
"""

0 commit comments

Comments
 (0)