8000 Hide "inner" {x,y}labels in label_outer too. · matplotlib/matplotlib@27d669c · GitHub
[go: up one dir, main page]

Skip to content

Commit 27d669c

Browse files
committed
Hide "inner" {x,y}labels in label_outer too.
`ax.label_outer` used to hide only "inner" ticklabels; make it hide axes labels too. (I couldn't find a way to just switch label visibility, so I just set the labels to the empty string instead.)
1 parent 1214b21 commit 27d669c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/matplotlib/axes/_subplots.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,23 @@ def is_last_col(self):
127127

128128
# COVERAGE NOTE: Never used internally or from examples
129129
def label_outer(self):
130-
"""
131-
set the visible property on ticklabels so xticklabels are
132-
visible only if the subplot is in the last row and yticklabels
133-
are visible only if the subplot is in the first column
130+
"""Only show "outer" labels and tick labels.
131+
132+
x-labels are only kept for subplots on the last row; y-labels only for
133+
subplots on the first column.
134134
"""
135135
lastrow = self.is_last_row()
136136
firstcol = self.is_first_col()
137137
for label in self.get_xticklabels():
138138
label.set_visible(lastrow)
139139
self.get_xaxis().get_offset_text().set_visible(lastrow)
140+
if not lastrow:
141+
self.set_xlabel("")
140142
for label in self.get_yticklabels():
141143
label.set_visible(firstcol)
142144
self.get_yaxis().get_offset_text().set_visible(firstcol)
145+
if not firstcol:
146+
self.set_ylabel("")
143147

144148
def _make_twin_axes(self, *kl, **kwargs):
145149
"""

0 commit comments

Comments
 (0)
0