Skip to content

Cleanup delaxes() #9928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 5 additions & 10 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down