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)
| 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.""" |