@@ -23,10 +23,9 @@ def _auto_adjust_subplotpars(
23
23
Return a dict of subplot parameters to adjust spacing between subplots
24
24
or ``None`` if resulting axes would have zero height or width.
25
25
26
- Note that this function ignores geometry information of subplot
27
- itself, but uses what is given by the *nrows_ncols* and *num1num2_list*
28
- parameters. Also, the results could be incorrect if some subplots have
29
- ``adjustable=datalim``.
26
+ Note that this function ignores geometry information of subplot itself, but
27
+ uses what is given by the *shape* and *subplot_list* parameters. Also, the
28
+ results could be incorrect if some subplots have ``adjustable=datalim``.
30
29
31
30
Parameters
32
31
----------
@@ -47,11 +46,11 @@ def _auto_adjust_subplotpars(
47
46
"""
48
47
rows , cols = shape
49
48
50
- font_size_inches = (
49
+ font_size_inch = (
51
50
FontProperties (size = rcParams ["font.size" ]).get_size_in_points () / 72 )
52
- pad_inches = pad * font_size_inches
53
- vpad_inches = h_pad * font_size_inches if h_pad is not None else pad_inches
54
- hpad_inches = w_pad * font_size_inches if w_pad is not None else pad_inches
51
+ pad_inch = pad * font_size_inch
52
+ vpad_inch = h_pad * font_size_inch if h_pad is not None else pad_inch
53
+ hpad_inch = w_pad * font_size_inch if w_pad is not None else pad_inch
55
54
56
55
if len (span_pairs ) != len (subplot_list ) or len (subplot_list ) == 0 :
57
56
raise ValueError
@@ -98,42 +97,37 @@ def _auto_adjust_subplotpars(
98
97
# margins can be negative for axes with aspect applied, so use max(, 0) to
99
98
# make them nonnegative.
100
99
if not margin_left :
101
- margin_left = (max (hspaces [:, 0 ].max (), 0 )
102
- + pad_inches / fig_width_inch )
100
+ margin_left = max (hspaces [:, 0 ].max (), 0 ) + pad_inch / fig_width_inch
103
101
suplabel = fig ._supylabel
104
102
if suplabel and suplabel .get_in_layout ():
105
103
rel_width = fig .transFigure .inverted ().transform_bbox (
106
104
suplabel .get_window_extent (renderer )).width
107
- margin_left += rel_width + pad_inches / fig_width_inch
108
-
105
+ margin_left += rel_width + pad_inch / fig_width_inch
109
106
if not margin_right :
110
- margin_right = (max (hspaces [:, - 1 ].max (), 0 )
111
- + pad_inches / fig_width_inch )
107
+ margin_right = max (hspaces [:, - 1 ].max (), 0 ) + pad_inch / fig_width_inch
112
108
if not margin_top :
113
- margin_top = (max (vspaces [0 , :].max (), 0 )
114
- + pad_inches / fig_height_inch )
109
+ margin_top = max (vspaces [0 , :].max (), 0 ) + pad_inch / fig_height_inch
115
110
if fig ._suptitle and fig ._suptitle .get_in_layout ():
116
111
rel_height = fig .transFigure .inverted ().transform_bbox (
117
112
fig ._suptitle .get_window_extent (renderer )).height
118
- margin_top += rel_height + pad_inches / fig_height_inch
113
+ margin_top += rel_height + pad_inch / fig_height_inch
119
114
if not margin_bottom :
120
- margin_bottom = (max (vspaces [- 1 , :].max (), 0 )
121
- + pad_inches / fig_height_inch )
115
+ margin_bottom = max (vspaces [- 1 , :].max (), 0 ) + pad_inch / fig_height_inch
122
116
suplabel = fig ._supxlabel
123
117
if suplabel and suplabel .get_in_layout ():
124
118
rel_height = fig .transFigure .inverted ().transform_bbox (
125
119
suplabel .get_window_extent (renderer )).height
126
- margin_bottom += rel_height + pad_inches / fig_height_inch
120
+ margin_bottom += rel_height + pad_inch / fig_height_inch
127
121
128
122
if margin_left + margin_right >= 1 :
129
123
_api .warn_external ('Tight layout not applied. The left and right '
130
124
'margins cannot be made large enough to '
131
- 'accommodate all axes decorations. ' )
125
+ 'accommodate all axes decorations.' )
132
126
return None
133
127
if margin_bottom + margin_top >= 1 :
134
128
_api .warn_external ('Tight layout not applied. The bottom and top '
135
129
'margins cannot be made large enough to '
136
- 'accommodate all axes decorations. ' )
130
+ 'accommodate all axes decorations.' )
137
131
return None
138
132
139
133
kwargs = dict (left = margin_left ,
@@ -142,7 +136,7 @@ def _auto_adjust_subplotpars(
142
136
top = 1 - margin_top )
143
137
144
138
if cols > 1 :
145
- hspace = hspaces [:, 1 :- 1 ].max () + hpad_inches / fig_width_inch
139
+ hspace = hspaces [:, 1 :- 1 ].max () + hpad_inch / fig_width_inch
146
140
# axes widths:
147
141
h_axes = (1 - margin_right - margin_left - hspace * (cols - 1 )) / cols
148
142
if h_axes < 0 :
@@ -153,12 +147,12 @@ def _auto_adjust_subplotpars(
153
147
else :
154
148
kwargs ["wspace" ] = hspace / h_axes
155
149
if rows > 1 :
156
- vspace = vspaces [1 :- 1 , :].max () + vpad_inches / fig_height_inch
150
+ vspace = vspaces [1 :- 1 , :].max () + vpad_inch / fig_height_inch
157
151
v_axes = (1 - margin_top - margin_bottom - vspace * (rows - 1 )) / rows
158
152
if v_axes < 0 :
159
153
_api .warn_external ('Tight layout not applied. tight_layout '
160
154
'cannot make axes height small enough to '
161
- 'accommodate all axes decorations' )
155
+ 'accommodate all axes decorations. ' )
162
156
return None
163
157
else :
164
158
kwargs ["hspace" ] = vspace / v_axes
0 commit comments