11
11
12
12
import numpy as np
13
13
14
- from matplotlib import _api , rcParams
14
+ from matplotlib import _api , docstring , rcParams
15
15
from matplotlib .font_manager import FontProperties
16
16
from matplotlib .transforms import TransformedBbox , Bbox
17
17
18
18
19
- def auto_adjust_subplotpars (
19
+ def _auto_adjust_subplotpars (
20
20
fig , renderer , nrows_ncols , num1num2_list , subplot_list ,
21
21
ax_bbox_list = None , pad = 1.08 , h_pad = None , w_pad = None , rect = None ):
22
22
"""
@@ -90,8 +90,6 @@ def auto_adjust_subplotpars(
90
90
fig .transFigure .inverted ())
91
91
92
92
row1 , col1 = divmod (num1 , cols )
93
- if num2 is None :
94
- num2 = num1
95
93
row2 , col2 = divmod (num2 , cols )
96
94
97
95
for row_i in range (row1 , row2 + 1 ):
@@ -174,6 +172,18 @@ def auto_adjust_subplotpars(
174
172
return kwargs
175
173
176
174
175
+ @_api .deprecated ("3.5" )
1
10000
76
+ @docstring .copy (_auto_adjust_subplotpars )
177
+ def auto_adjust_subplotpars (
178
+ fig , renderer , nrows_ncols , num1num2_list , subplot_list ,
179
+ ax_bbox_list = None , pad = 1.08 , h_pad = None , w_pad = None , rect = None ):
180
+ num1num2_list = [
181
+ (n1 , n1 if n2 is None else n2 ) for n1 , n2 in num1num2_list ]
182
+ return _auto_adjust_subplotpars (
183
+ fig , renderer , nrows_ncols , num1num2_list , subplot_list ,
184
+ ax_bbox_list , pad , h_pad , w_pad , rect )
185
+
186
+
177
187
def get_renderer (fig ):
178
188
if fig ._cachedRenderer :
179
189
return fig ._cachedRenderer
@@ -298,23 +308,19 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
298
308
'multiples of one another.' )
299
309
return {}
300
310
301
- rowNum1 , colNum1 = divmod (num1 , cols )
302
- if num2 is None :
303
- rowNum2 , colNum2 = rowNum1 , colNum1
304
- else :
305
- rowNum2 , colNum2 = divmod (num2 , cols )
311
+ row1 , col1 = divmod (num1 , cols )
312
+ row2 , col2 = divmod (num2 , cols )
306
313
307
- num1num2_list .append ((rowNum1 * div_row * max_ncols +
308
- colNum1 * div_col ,
309
- ((rowNum2 + 1 ) * div_row - 1 ) * max_ncols +
310
- (colNum2 + 1 ) * div_col - 1 ))
314
+ num1num2_list .append ((row1 * div_row * max_ncols + col1 * div_col ,
315
+ ((row2 + 1 ) * div_row - 1 ) * max_ncols +
316
+ (col2 + 1 ) * div_col - 1 ))
311
317
312
- kwargs = auto_adjust_subplotpars (fig , renderer ,
313
- nrows_ncols = (max_nrows , max_ncols ),
314
- num1num2_list = num1num2_list ,
315
- subplot_list = subplot_list ,
316
- ax_bbox_list = ax_bbox_list ,
317
- pad = pad , h_pad = h_pad , w_pad = w_pad )
318
+ kwargs = _auto_adjust_subplotpars (fig , renderer ,
319
+ nrows_ncols = (max_nrows , max_ncols ),
320
+ num1num2_list = num1num2_list ,
321
+ subplot_list = subplot_list ,
322
+ ax_bbox_list = ax_bbox_list ,
323
+ pad = pad , h_pad = h_pad , w_pad = w_pad )
318
324
319
325
# kwargs can be none if tight_layout fails...
320
326
if rect is not None and kwargs is not None :
@@ -336,12 +342,12 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
336
342
if top is not None :
337
343
top -= (1 - kwargs ["top" ])
338
344
339
- kwargs = auto_adjust_subplotpars (fig , renderer ,
340
- nrows_ncols = (max_nrows , max_ncols ),
341
- num1num2_list = num1num2_list ,
342
- subplot_list = subplot_list ,
343
- ax_bbox_list = ax_bbox_list ,
344
- pad = pad , h_pad = h_pad , w_pad = w_pad ,
345
- rect = (left , bottom , right , top ))
345
+ kwargs = _auto_adjust_subplotpars (fig , renderer ,
346
+ nrows_ncols = (max_nrows , max_ncols ),
347
+ num1num2_list = num1num2_list ,
348
+ subplot_list = subplot_list ,
349
+ ax_bbox_list = ax_bbox_list ,
350
+ pad = pad , h_pad = h_pad , w_pad = w_pad ,
351
+ rect = (left , bottom , right , top ))
346
352
347
353
return kwargs
0 commit comments