diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 416b87d4a5f9..e3d86e3f8438 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -864,9 +864,11 @@ def set_frameon(self, b): self.frameon = b self.stale = True - def delaxes(self, a): - 'remove a from the figure and update the current axes' - self._axstack.remove(a) + def delaxes(self, ax): + """ + Remove the `~.Axes` *ax* from the figure and update the current axes. + """ + self._axstack.remove(ax) for func in self._axobservers: func(self) self.stale = True diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index df71cb2a7ac3..f33f25a1a394 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -919,19 +919,14 @@ def axes(*args, **kwargs): return a -def delaxes(*args): +def delaxes(ax=None): """ - Remove an axes from the current figure. If *ax* - doesn't exist, an error will be raised. - - ``delaxes()``: delete the current axes + Remove the given `Axes` *ax* from the current figure. If *ax* is *None*, + the current axes is removed. A KeyError is raised if the axes doesn't exist. """ - if not len(args): + if ax is None: ax = gca() - else: - ax = args[0] - ret = gcf().delaxes(ax) - return ret + gcf().delaxes(ax) def sca(ax):