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

Skip to content

Commit 01c4b90

Browse files
committed
ENH: pull apart Artist state when removing
- disconnect the stale_callback (this assumes that #4738 goes in) - remove the artist from the Axes.mousover_set - marks the parent axes/figure as stale - resets the artist's axes/figure to None
1 parent 1133214 commit 01c4b90

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/matplotlib/artist.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ def remove(self):
147147
# callback has one parameter, which is the child to be removed.
148148
if self._remove_method is not None:
149149
self._remove_method(self)
150+
# clear stale callback
151+
self.stale_callback = None
152+
_ax_flag = False
153+
if hasattr(self, 'axes') and self.axes:
154+
# remove from the mouse hit list
155+
self.axes.mouseover_set.discard(self)
156+
# mark the axes as stale
157+
self.axes.stale = True
158+
# decouple the artist from the axes
159+
self.axes = None
160+
_ax_flag = True
161+
162+
if self.figure:
163+
self.figure = None
164+
if not _ax_flag:
165+
self.figure = True
166+
150167
else:
151168
raise NotImplementedError('cannot remove artist')
152169
# TODO: the fix for the collections relim problem is to move the

0 commit comments

Comments
 (0)