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

Commit0e87f48

Browse files
authored
Merge pull request#18306 from richardsheridan/fix_configure_subplots
Fix configure subplots
2 parentse3c2b31 +2c9a85b commit0e87f48

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

‎lib/matplotlib/_pylab_helpers.py

Lines 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-
ifall(hasattr(num,attr)forattrin ["num","_cidgcf","destroy"]):
56+
ifall(hasattr(num,attr)forattrin ["num","destroy"]):
5757
manager=num
5858
ifcls.figs.get(manager.num)ismanager:
5959
cls.figs.pop(manager.num)
60-
else:
61-
return
6260
else:
6361
try:
6462
manager=cls.figs.pop(num)
6563
exceptKeyError:
6664
return
67-
manager.canvas.mpl_disconnect(manager._cidgcf)
65+
ifhasattr(manager,"_cidgcf"):
66+
manager.canvas.mpl_disconnect(manager._cidgcf)
6867
manager.destroy()
6968
gc.collect(1)
7069

‎lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,8 +3294,8 @@ def _update_view(self):
32943294

32953295
defconfigure_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
defsave_figure(self,*args):
33013301
"""Save the current figure."""

‎lib/matplotlib/backends/backend_nbagg.py

Lines 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
ifis_interactive():
232232
manager.show()
233233
figure.canvas.draw_idle()
234-
canvas.mpl_connect('close_event',lambdaevent:Gcf.destroy(manager))
234+
235+
defdestroy(event):
236+
canvas.mpl_disconnect(cid)
237+
Gcf.destroy(manager)
238+
239+
cid=canvas.mpl_connect('close_event',destroy)
235240
returnmanager
236241

237242
@staticmethod

‎lib/matplotlib/pyplot.py

Lines 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
iftargetfigisNone:
15521553
targetfig=gcf()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp