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

Appearance settings

Commit 0e87f48

Browse filesBrowse files
authored
Merge pull request #18306 from richardsheridan/fix_configure_subplots
Fix configure subplots
2 parents e3c2b31 + 2c9a85b commit 0e87f48
Copy full SHA for 0e87f48

File tree

Expand file treeCollapse file tree

4 files changed

+13
-8
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+13
-8
lines changed

‎lib/matplotlib/_pylab_helpers.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_pylab_helpers.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,17 @@ def destroy(cls, num):
5353
It is recommended to pass a manager instance, to avoid confusion when
5454
two managers share the same number.
5555
"""
56-
if all(hasattr(num, attr) for attr in ["num", "_cidgcf", "destroy"]):
56+
if all(hasattr(num, attr) for attr in ["num", "destroy"]):
5757
manager = num
5858
if cls.figs.get(manager.num) is manager:
5959
cls.figs.pop(manager.num)
60-
else:
61-
return
6260
else:
6361
try:
6462
manager = cls.figs.pop(num)
6563
except KeyError:
6664
return
67-
manager.canvas.mpl_disconnect(manager._cidgcf)
65+
if hasattr(manager, "_cidgcf"):
66+
manager.canvas.mpl_disconnect(manager._cidgcf)
6867
manager.destroy()
6968
gc.collect(1)
7069

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,8 +3294,8 @@ def _update_view(self):
32943294

32953295
def configure_subplots(self, *args):
32963296
plt = _safe_pyplot_import()
3297-
tool = plt.subplot_tool(self.canvas.figure)
3298-
tool.figure.canvas.manager.show()
3297+
self.subplot_tool = plt.subplot_tool(self.canvas.figure)
3298+
self.subplot_tool.figure.canvas.manager.show()
32993299

33003300
def save_figure(self, *args):
33013301
"""Save the current figure."""

‎lib/matplotlib/backends/backend_nbagg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_nbagg.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,12 @@ def new_figure_manager_given_figure(num, figure):
231231
if is_interactive():
232232
manager.show()
233233
figure.canvas.draw_idle()
234-
canvas.mpl_connect('close_event', lambda event: Gcf.destroy(manager))
234+
235+
def destroy(event):
236+
canvas.mpl_disconnect(cid)
237+
Gcf.destroy(manager)
238+
239+
cid = canvas.mpl_connect('close_event', destroy)
235240
return manager
236241

237242
@staticmethod

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,8 @@ def subplot_tool(targetfig=None):
15461546
"""
15471547
Launch a subplot tool window for a figure.
15481548
1549-
A `matplotlib.widgets.SubplotTool` instance is returned.
1549+
A `matplotlib.widgets.SubplotTool` instance is returned. You must maintain
1550+
a reference to the instance to keep the associated callbacks alive.
15501551
"""
15511552
if targetfig is None:
15521553
targetfig = gcf()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.