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

Skip to content

Commit 9dfcfd5

Browse files
committed
Clear toolbars only in Figure
1 parent 7325061 commit 9dfcfd5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/matplotlib/figure.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,6 @@ def clf(self, keep_observers=False):
956956
ax.cla()
957957
self.delaxes(ax) # Remove ax from self._axstack.
958958

959-
toolbar = getattr(self.canvas, 'toolbar', None)
960-
if toolbar is not None:
961-
toolbar.update()
962959
self.artists = []
963960
self.subfigs = []
964961
self.lines = []
@@ -2783,7 +2780,19 @@ def set_figheight(self, val, forward=True):
27832780
"""
27842781
self.set_size_inches(self.get_figwidth(), val, forward=forward)
27852782

2783+
def clf(self, keep_observers=False):
2784+
"""
2785+
Clear the figure.
27862786
2787+
Set *keep_observers* to True if, for example,
2788+
a gui widget is tracking the Axes in the figure.
2789+
"""
2790+
super().clf(keep_observers=keep_observers)
2791+
# FigureBase.clf does not clear toolbars, as
2792+
# only Figure can have toolbars
2793+
toolbar = getattr(self.canvas, 'toolbar', None)
2794+
if toolbar is not None:
2795+
toolbar.update()
27872796

27882797
@_finalize_rasterization
27892798
@allow_rasterization

0 commit comments

Comments
 (0)