Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb19e7c

Browse files
committed
Merge v1.4.x into master
Conflicts: .travis.yml lib/matplotlib/tests/test_axes.py lib/matplotlib/tests/test_text.py lib/matplotlib/tests/test_transforms.py lib/matplotlib/transforms.py
2 parents b90e2b3 + b8a5f91 commit bb19e7c

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,16 @@ def _gen_axes_spines(self, locations=None, offset=0.0, units='inches'):
817817
def cla(self):
818818
"""Clear the current axes."""
819819
# Note: this is called by Axes.__init__()
820+
821+
# stash the current visibility state
822+
if hasattr(self, 'patch'):
823+
patch_visible = self.patch.get_visible()
824+
else:
825+
patch_visible = True
826+
827+
xaxis_visible = self.xaxis.get_visible()
828+
yaxis_visible = self.yaxis.get_visible()
829+
820830
self.xaxis.cla()
821831
self.yaxis.cla()
822832
for name, spine in six.iteritems(self.spines):
@@ -942,6 +952,13 @@ def cla(self):
942952

943953
self._shared_x_axes.clean()
944954
self._shared_y_axes.clean()
955+
if self._sharex:
956+
self.xaxis.set_visible(xaxis_visible)
957+
self.patch.set_visible(patch_visible)
958+
959+
if self._sharey:
960+
self.yaxis.set_visible(yaxis_visible)
961+
self.patch.set_visible(patch_visible)
945962

946963
def clear(self):
947964
"""clear the axes"""

lib/matplotlib/tests/test_axes.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import io
88

9-
from nose.tools import assert_equal, assert_raises
9+
from nose.tools import assert_equal, assert_raises, assert_false, assert_true
10+
1011
import datetime
1112

1213
import numpy as np
@@ -102,6 +103,30 @@ def test_twin_axis_locaters_formatters():
102103
ax3 = ax1.twinx()
103104

104105

106+
@cleanup
107+
def test_twinx_cla():
108+
fig, ax = plt.subplots()
109+
ax2 = ax.twinx()
110+
ax3 = ax2.twiny()
111+
plt.draw()
112+
assert_false(ax2.xaxis.get_visible())
113+
assert_false(ax2.patch.get_visible())
114+
ax2.cla()
115+
ax3.cla()
116+
117+
assert_false(ax2.xaxis.get_visible())
118+
assert_false(ax2.patch.get_visible())
119+
assert_true(ax2.yaxis.get_visible())
120+
121+
assert_true(ax3.xaxis.get_visible())
122+
assert_false(ax3.patch.get_visible())
123+
assert_false(ax3.yaxis.get_visible())
124+
125+
assert_true(ax.xaxis.get_visible())
126+
assert_true(ax.patch.get_visible())
127+
assert_true(ax.yaxis.get_visible())
128+
129+
105130
@image_comparison(baseline_images=["autoscale_tiny_range"], remove_text=True)
106131
def test_autoscale_tiny_range():
107132
# github pull #904

lib/matplotlib/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ def transform(self, values):
13001300

13011301
# Convert the result back to the shape of the input values.
13021302
if ndim == 0:
1303-
assert not np.ma.is_masked(res) # just to be on the safe side
1303+
assert not np.ma.is_masked(res) # just to be on the safe side
13041304
return res[0, 0]
13051305
if ndim == 1:
13061306
return res.reshape(-1)

0 commit comments

Comments
 (0)