@@ -2084,7 +2084,7 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
2084
2084
pad = pad , h_pad = h_pad , w_pad = w_pad , rect = rect )
2085
2085
self .subplots_adjust (** kwargs )
2086
2086
2087
- def align_xlabels (self , axs = None , renderer = None ):
2087
+ def align_xlabels (self , axs = None ):
2088
2088
"""
2089
2089
Align the xlabels of subplots in this figure.
2090
2090
@@ -2099,9 +2099,6 @@ def align_xlabels(self, axs=None, renderer=None):
2099
2099
Optional list of `~matplotlib.axes.Axes` to align
2100
2100
the xlabels.
2101
2101
2102
- renderer : (None)
2103
- Optional renderer to do the adjustment on.
2104
-
2105
2102
See Also
2106
2103
--------
2107
2104
matplotlib.figure.Figure.align_ylabels
@@ -2121,11 +2118,6 @@ def align_xlabels(self, axs=None, renderer=None):
2121
2118
2122
2119
"""
2123
2120
2124
- from .tight_layout import get_renderer
2125
-
2126
- if renderer is None :
2127
- renderer = get_renderer (self )
2128
-
2129
2121
if axs is None :
2130
2122
axs = self .axes
2131
2123
@@ -2135,23 +2127,24 @@ def align_xlabels(self, axs=None, renderer=None):
2135
2127
_log .debug (' Working on: %s' , ax .get_xlabel ())
2136
2128
ss = ax .get_subplotspec ()
2137
2129
nrows , ncols , row0 , row1 , col0 , col1 = ss .get_rows_columns ()
2138
- same = [ax ]
2139
- labpo = ax .xaxis .get_label_position ()
2130
+ labpo = ax .xaxis .get_label_position () # top or bottom
2131
+
2132
+ # loop through other axes, and search for label positions
2133
+ # that are same as this one, and that share the appropriate
2134
+ # row number.
2135
+ # Add to a list associated with each axes of sibblings.
2136
+ # This list is inspected in `axis.draw` by
2137
+ # `axis._update_label_position`.
2140
2138
for axc in axs :
2141
2139
if axc .xaxis .get_label_position () == labpo :
2142
2140
ss = axc .get_subplotspec ()
2143
2141
nrows , ncols , rowc0 , rowc1 , colc , col1 = \
2144
2142
ss .get_rows_columns ()
2145
- if (labpo == 'bottom' ) and (rowc1 == row1 ):
2146
- same += [axc ]
2147
- elif (labpo == 'top' ) and (rowc0 == row0 ):
2148
- same += [axc ]
2149
-
2150
- for axx in same :
2151
- _log .debug (' Same: %s' , axx .xaxis .label )
2152
- axx .xaxis ._align_label_siblings += [ax .xaxis ]
2143
+ if (((labpo == 'bottom' ) and (rowc1 == row1 )) or
2144
+ ((labpo == 'top' ) and (rowc0 == row0 ))):
2145
+ axc .xaxis ._align_label_siblings += [ax .xaxis ]
2153
2146
2154
- def align_ylabels (self , axs = None , renderer = None ):
2147
+ def align_ylabels (self , axs = None ):
2155
2148
"""
2156
2149
Align the ylabels of subplots in this figure.
2157
2150
@@ -2166,9 +2159,6 @@ def align_ylabels(self, axs=None, renderer=None):
2166
2159
Optional list of `~matplotlib.axes.Axes` to align
2167
2160
the ylabels.
2168
2161
2169
- renderer : (None)
2170
- Optional renderer to do the adjustment on.
2171
-
2172
2162
See Also
2173
2163
--------
2174
2164
matplotlib.figure.Figure.align_xlabels
@@ -2187,11 +2177,6 @@ def align_ylabels(self, axs=None, renderer=None):
2187
2177
2188
2178
"""
2189
2179
2190
- from .tight_layout import get_renderer
2191
-
2192
- if renderer is None :
2193
- renderer = get_renderer (self )
2194
-
2195
2180
if axs is None :
2196
2181
axs = self .axes
2197
2182
@@ -2208,13 +2193,9 @@ def align_ylabels(self, axs=None, renderer=None):
2208
2193
ss = axc .get_subplotspec ()
2209
2194
nrows , ncols , row0 , row1 , colc0 , colc1 = \
2210
2195
ss .get_rows_columns ()
2211
- if (labpo == 'left' ) and (colc0 == col0 ):
2212
- same += [axc ]
2213
- elif (labpo == 'right' ) and (colc1 == col1 ):
2214
- same += [axc ]
2215
- for axx in same :
2216
- _log .debug (' Same: %s' , axx .yaxis .label )
2217
- axx .yaxis ._align_label_siblings += [ax .yaxis ]
2196
+ if (((labpo == 'left' ) and (colc0 == col0 )) or
2197
+ ((labpo == 'right' ) and (colc1 == col1 ))):
2198
+ axc .yaxis ._align_label_siblings += [ax .yaxis ]
2218
2199
2219
2200
# place holder until #9498 is merged...
2220
2201
def align_titles (self , axs = None , renderer = None ):
@@ -2268,7 +2249,7 @@ def align_titles(self, axs=None, renderer=None):
2268
2249
ax .title .set_position (x0 , y )
2269
2250
y0 = y
2270
2251
elif y0 > y :
2271
- axx .title .set_positions (x , y0 )
2252
+ axx .title .set_position (x , y0 )
2272
2253
2273
2254
def align_labels (self , axs = None , renderer = None ):
2274
2255
"""
@@ -2290,9 +2271,8 @@ def align_labels(self, axs=None, renderer=None):
2290
2271
2291
2272
matplotlib.figure.Figure.align_ylabels
2292
2273
"""
2293
- self .align_xlabels (axs = axs , renderer = renderer )
2294
- self .align_ylabels (axs = axs , renderer = renderer )
2295
- # self.align_titles(axs=axs, renderer=renderer)
2274
+ self .align_xlabels (axs = axs )
2275
+ self .align_ylabels (axs = axs )
2296
2276
2297
2277
2298
2278
def figaspect (arg ):
0 commit comments