Skip to content

Commit

Permalink
Also hide offsetText when using label_outer.
Browse files Browse the repository at this point in the history
Partially fixes #4445.
  • Loading branch information
anntzer committed Mar 22, 2016
1 parent c1aecd1 commit 91b3019
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/matplotlib/axes/_subplots.py
Expand Up @@ -136,9 +136,10 @@ def label_outer(self):
firstcol = self.is_first_col()
for label in self.get_xticklabels():
label.set_visible(lastrow)

self.get_xaxis().get_offset_text().set_visible(lastrow)
for label in self.get_yticklabels():
label.set_visible(firstcol)
self.get_yaxis().get_offset_text().set_visible(firstcol)

def _make_twin_axes(self, *kl, **kwargs):
"""
Expand Down
13 changes: 11 additions & 2 deletions lib/matplotlib/tests/test_subplots.py
Expand Up @@ -37,10 +37,10 @@ def check_shared(results, f, axs):
def check_visible(result, f, axs):
tostr = lambda v: "invisible" if v else "visible"
for (ax, vx, vy) in zip(axs, result['x'], result['y']):
for l in ax.get_xticklabels():
for l in ax.get_xticklabels() + [ax.get_xaxis().offsetText]:
assert l.get_visible() == vx, \
"X axis was incorrectly %s" % (tostr(vx))
for l in ax.get_yticklabels():
for l in ax.get_yticklabels() + [ax.get_yaxis().offsetText]:
assert l.get_visible() == vy, \
"Y axis was incorrectly %s" % (tostr(vy))

Expand Down Expand Up @@ -101,6 +101,15 @@ def test_shared():
f, axs)
plt.close(f)

# test label_outer
f, ((a1, a2), (a3, a4)) = plt.subplots(2, 2, sharex=True, sharey=True)
axs = [a1, a2, a3, a4]
for ax in axs:
ax.label_outer()
check_visible(
{'x': [False, False, True, True], 'y': [True, False, True, False]}, f, axs)



def test_exceptions():
# TODO should this test more options?
Expand Down

0 comments on commit 91b3019

Please sign in to comment.