Skip to content

Commit

Permalink
BUG : fix cla behavior with twinx
Browse files Browse the repository at this point in the history
Closes matplotlib#3633

Added more special-case logic for twined axes.

This needs a test
  • Loading branch information
tacaswell committed Oct 11, 2014
1 parent 68b34b0 commit 9ba3872
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/matplotlib/axes/_base.py
Expand Up @@ -816,6 +816,16 @@ def _gen_axes_spines(self, locations=None, offset=0.0, units='inches'):
def cla(self):
"""Clear the current axes."""
# Note: this is called by Axes.__init__()

# stash the current visibility state
if hasattr(self, 'patch'):
patch_visible = self.patch.get_visible()
else:
patch_visible = True

yaxis_visible = self.xaxis.get_visible()
xaxis_visible = self.yaxis.get_visible()

self.xaxis.cla()
self.yaxis.cla()
for name, spine in six.iteritems(self.spines):
Expand Down Expand Up @@ -941,6 +951,13 @@ def cla(self):

self._shared_x_axes.clean()
self._shared_y_axes.clean()
if self._sharex:
self.xaxis.set_visible(xaxis_visible)
self.patch.set_visible(patch_visible)

if self._sharey:
self.yaxis.set_visible(yaxis_visible)
self.patch.set_visible(patch_visible)

def clear(self):
"""clear the axes"""
Expand Down

0 comments on commit 9ba3872

Please sign in to comment.