Skip to content

Commit 631e9f1

Browse files
committed
Fix configure_subplots with tool manager
`configure_subplots` requires a) an object from which it can get the `canvas` property, and b) somewhere it can store its handle for re-use. The pseudo-toolbar that is used for most `Tool` classes is temporary and does not provide the latter. However, tools inherit from `ToolBase` which contains a `canvas` property and they exist for the lifetime of the toolbar, so can be used instead. Fixes #22088
1 parent 91f3465 commit 631e9f1

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lib/matplotlib/backends/_backend_gtk.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ def remove_rubberband(self):
295295

296296
class ConfigureSubplotsGTK(backend_tools.ConfigureSubplotsBase):
297297
def trigger(self, *args):
298-
_NavigationToolbar2GTK.configure_subplots(
299-
self._make_classic_style_pseudo_toolbar(), None)
298+
_NavigationToolbar2GTK.configure_subplots(self, None)
300299

301300

302301
class _BackendGTK(_Backend):

lib/matplotlib/backends/_backend_tk.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,7 @@ def trigger(self, *args):
934934
@backend_tools._register_tool_class(FigureCanvasTk)
935935
class ConfigureSubplotsTk(backend_tools.ConfigureSubplotsBase):
936936
def trigger(self, *args):
937-
NavigationToolbar2Tk.configure_subplots(
938-
self._make_classic_style_pseudo_toolbar())
937+
NavigationToolbar2Tk.configure_subplots(self)
939938

940939

941940
@backend_tools._register_tool_class(FigureCanvasTk)

lib/matplotlib/backends/backend_qt.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,12 @@ def set_message(self, s):
985985

986986
@backend_tools._register_tool_class(FigureCanvasQT)
987987
class ConfigureSubplotsQt(backend_tools.ConfigureSubplotsBase):
988+
def __init__(self, *args, **kwargs):
989+
super().__init__(*args, **kwargs)
990+
self._subplot_dialog = None
991+
988992
def trigger(self, *args):
989-
NavigationToolbar2QT.configure_subplots(
990-
self._make_classic_style_pseudo_toolbar())
993+
NavigationToolbar2QT.configure_subplots(self)
991994

992995

993996
@backend_tools._register_tool_class(FigureCanvasQT)

lib/matplotlib/backends/backend_wx.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,7 @@ def set_message(self, s):
12421242
@backend_tools._register_tool_class(_FigureCanvasWxBase)
12431243
class ConfigureSubplotsWx(backend_tools.ConfigureSubplotsBase):
12441244
def trigger(self, *args):
1245-
NavigationToolbar2Wx.configure_subplots(
1246-
self._make_classic_style_pseudo_toolbar())
1245+
NavigationToolbar2Wx.configure_subplots(self)
12471246

12481247

12491248
@backend_tools._register_tool_class(_FigureCanvasWxBase)

0 commit comments

Comments
 (0)