MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / remove

Method remove

lib/matplotlib/artist.py:235–270  ·  view source on GitHub ↗

Remove the artist from the figure if possible. The effect will not be visible until the figure is redrawn, e.g., with `.FigureCanvasBase.draw_idle`. Call `~.axes.Axes.relim` to update the Axes limits if desired. Note: there is no support for removing the a

(self)

Source from the content-addressed store, hash-verified

233 return d
234
235 def remove(self):
236 """
237 Remove the artist from the figure if possible.
238
239 The effect will not be visible until the figure is redrawn, e.g.,
240 with `.FigureCanvasBase.draw_idle`. Call `~.axes.Axes.relim` to
241 update the Axes limits if desired.
242
243 Note: there is no support for removing the artist's legend entry.
244 """
245
246 # There is no method to set the callback. Instead, the parent should
247 # set the _remove_method attribute directly. This would be a
248 # protected attribute if Python supported that sort of thing. The
249 # callback has one parameter, which is the child to be removed.
250 if self._remove_method is not None:
251 self._remove_method(self)
252 # clear stale callback
253 self.stale_callback = None
254 _ax_flag = False
255 ax = getattr(self, 'axes', None)
256 mouseover_set = getattr(ax, '_mouseover_set', None)
257 if mouseover_set is not None:
258 # remove from the mouse hit list
259 mouseover_set.discard(self)
260 ax.stale = True
261 self.axes = None # decouple the artist from the Axes
262 _ax_flag = True
263
264 if (fig := self.get_figure(root=False)) is not None:
265 if not _ax_flag:
266 fig.stale = True
267 self._parent_figure = None
268
269 else:
270 raise NotImplementedError('cannot remove artist')
271
272 def have_units(self):
273 """Return whether units are set on any axis."""

Callers 15

_3d_extend_contourMethod · 0.45
_remove_any_twinMethod · 0.45
test_removalFunction · 0.45
match_submerged_marginsFunction · 0.45
_auto_sized_delimiterMethod · 0.45
_handle_toggleMethod · 0.45
delaxesFunction · 0.45
remove_callbackMethod · 0.45
_on_timerMethod · 0.45
vendor_schemas.pyFile · 0.45
autodoc_process_basesFunction · 0.45

Calls 2

get_figureMethod · 0.95
discardMethod · 0.80

Tested by 2

test_removalFunction · 0.36