1+ import matplotlib as mpl
12from matplotlib import _api , cbook
23from matplotlib .axes ._axes import Axes
34from matplotlib .gridspec import GridSpec , SubplotSpec
@@ -109,10 +110,13 @@ def label_outer(self):
109110 labels are on the top side); y-labels only for subplots on the first
110111 column (or last column, if labels are on the right side).
111112 """
112- self ._label_outer_xaxis ()
113- self ._label_outer_yaxis ()
113+ self ._label_outer_xaxis (check_patch = False )
114+ self ._label_outer_yaxis (check_patch = False )
114115
115- def _label_outer_xaxis (self ):
116+ def _label_outer_xaxis (self , * , check_patch ):
117+ # see documentation in label_outer.
118+ if check_patch and not isinstance (self .patch , mpl .patches .Rectangle ):
119+ return
116120 ss = self .get_subplotspec ()
117121 label_position = self .xaxis .get_label_position ()
118122 if not ss .is_first_row (): # Remove top label/ticklabels/offsettext.
@@ -128,7 +132,10 @@ def _label_outer_xaxis(self):
128132 if self .xaxis .offsetText .get_position ()[1 ] == 0 :
129133 self .xaxis .offsetText .set_visible (False )
130134
131- def _label_outer_yaxis (self ):
135+ def _label_outer_yaxis (self , * , check_patch ):
136+ # see documentation in label_outer.
137+ if check_patch and not isinstance (self .patch , mpl .patches .Rectangle ):
138+ return
132139 ss = self .get_subplotspec ()
133140 label_position = self .yaxis .get_label_position ()
134141 if not ss .is_first_col (): # Remove left label/ticklabels/offsettext.
0 commit comments