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

Commitd0958e4

Browse files
committed
Fix: properly decouple from pyplot and specific backends when destroying
When destroying a manager, replace the figure's canvas by afigure canvas base.
1 parentc718eae commitd0958e4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎lib/matplotlib/backends/backend_qt.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ def show(self):
664664
self.window.raise_()
665665

666666
defdestroy(self,*args):
667+
self.canvas.figure._set_base_canvas()
667668
# check for qApp first, as PySide deletes it in its atexit handler
668669
ifQtWidgets.QApplication.instance()isNone:
669670
return

‎lib/matplotlib/figure.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2642,7 +2642,7 @@ def __init__(self,
26422642
self._set_artist_props(self.patch)
26432643
self.patch.set_antialiased(False)
26442644

2645-
FigureCanvasBase(self)# Set self.canvas.
2645+
self._set_base_canvas()
26462646

26472647
ifsubplotparsisNone:
26482648
subplotpars=SubplotParams()
@@ -2996,6 +2996,15 @@ def get_constrained_layout_pads(self, relative=False):
29962996

29972997
returnw_pad,h_pad,wspace,hspace
29982998

2999+
def_set_base_canvas(self):
3000+
"""
3001+
Initialize self.canvas with a FigureCanvasBase instance.
3002+
3003+
This is used upon initialization of the Figure, but also
3004+
to reset the canvas when decoupling from pyplot.
3005+
"""
3006+
FigureCanvasBase(self)# Set self.canvas as a side-effect
3007+
29993008
defset_canvas(self,canvas):
30003009
"""
30013010
Set the canvas that contains the figure

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp