From 2fc62a4ecb146b4fc5b03c78be9a7ef8d4b2cab2 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Tue, 5 Dec 2017 02:20:27 +0100 Subject: [PATCH] cleanup delaxes() --- lib/matplotlib/figure.py | 8 +++++--- lib/matplotlib/pyplot.py | 15 +++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) 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):