Skip to content

Commit 91b3019

Browse files
committed
Also hide offsetText when using label_outer.
Partially fixes #4445.
1 parent c1aecd1 commit 91b3019

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/matplotlib/axes/_subplots.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ def label_outer(self):
136136
firstcol = self.is_first_col()
137137
for label in self.get_xticklabels():
138138
label.set_visible(lastrow)
139-
139+
self.get_xaxis().get_offset_text().set_visible(lastrow)
140140
for label in self.get_yticklabels():
141141
label.set_visible(firstcol)
142+
self.get_yaxis().get_offset_text().set_visible(firstcol)
142143

143144
def _make_twin_axes(self, *kl, **kwargs):
144145
"""

lib/matplotlib/tests/test_subplots.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def check_shared(results, f, axs):
3737
def check_visible(result, f, axs):
3838
tostr = lambda v: "invisible" if v else "visible"
3939
for (ax, vx, vy) in zip(axs, result['x'], result['y']):
40-
for l in ax.get_xticklabels():
40+
for l in ax.get_xticklabels() + [ax.get_xaxis().offsetText]:
4141
assert l.get_visible() == vx, \
4242
"X axis was incorrectly %s" % (tostr(vx))
43-
for l in ax.get_yticklabels():
43+
for l in ax.get_yticklabels() + [ax.get_yaxis().offsetText]:
4444
assert l.get_visible() == vy, \
4545
"Y axis was incorrectly %s" % (tostr(vy))
4646

@@ -101,6 +101,15 @@ def test_shared():
101101
f, axs)
102102
plt.close(f)
103103

104+
# test label_outer
105+
f, ((a1, a2), (a3, a4)) = plt.subplots(2, 2, sharex=True, sharey=True)
106+
axs = [a1, a2, a3, a4]
107+
for ax in axs:
108+
ax.label_outer()
109+
check_visible(
110+
{'x': [False, False, True, True], 'y': [True, False, True, False]}, f, axs)
111+
112+
104113

105114
def test_exceptions():
106115
# TODO should this test more options?

0 commit comments

Comments
 (0)