@@ -23,10 +23,9 @@ def _auto_adjust_subplotpars(
2323 Return a dict of subplot parameters to adjust spacing between subplots
2424 or ``None`` if resulting axes would have zero height or width.
2525
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``.
3029
3130 Parameters
3231 ----------
@@ -47,11 +46,11 @@ def _auto_adjust_subplotpars(
4746 """
4847 rows , cols = shape
4948
50- font_size_inches = (
49+ font_size_inch = (
5150 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
5554
5655 if len (span_pairs ) != len (subplot_list ) or len (subplot_list ) == 0 :
5756 raise ValueError
@@ -98,42 +97,37 @@ def _auto_adjust_subplotpars(
9897 # margins can be negative for axes with aspect applied, so use max(, 0) to
9998 # make them nonnegative.
10099 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
103101 suplabel = fig ._supylabel
104102 if suplabel and suplabel .get_in_layout ():
105103 rel_width = fig .transFigure .inverted ().transform_bbox (
106104 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
109106 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
112108 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
115110 if fig ._suptitle and fig ._suptitle .get_in_layout ():
116111 rel_height = fig .transFigure .inverted ().transform_bbox (
117112 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
119114 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
122116 suplabel = fig ._supxlabel
123117 if suplabel and suplabel .get_in_layout ():
124118 rel_height = fig .transFigure .inverted ().transform_bbox (
125119 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
127121
128122 if margin_left + margin_right >= 1 :
129123 _api .warn_external ('Tight layout not applied. The left and right '
130124 'margins cannot be made large enough to '
131- 'accommodate all axes decorations. ' )
125+ 'accommodate all axes decorations.' )
132126 return None
133127 if margin_bottom + margin_top >= 1 :
134128 _api .warn_external ('Tight layout not applied. The bottom and top '
135129 'margins cannot be made large enough to '
136- 'accommodate all axes decorations. ' )
130+ 'accommodate all axes decorations.' )
137131 return None
138132
139133 kwargs = dict (left = margin_left ,
@@ -142,7 +136,7 @@ def _auto_adjust_subplotpars(
142136 top = 1 - margin_top )
143137
144138 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
146140 # axes widths:
147141 h_axes = (1 - margin_right - margin_left - hspace * (cols - 1 )) / cols
148142 if h_axes < 0 :
@@ -153,12 +147,12 @@ def _auto_adjust_subplotpars(
153147 else :
154148 kwargs ["wspace" ] = hspace / h_axes
155149 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
157151 v_axes = (1 - margin_top - margin_bottom - vspace * (rows - 1 )) / rows
158152 if v_axes < 0 :
159153 _api .warn_external ('Tight layout not applied. tight_layout '
160154 'cannot make axes height small enough to '
161- 'accommodate all axes decorations' )
155+ 'accommodate all axes decorations. ' )
162156 return None
163157 else :
164158 kwargs ["hspace" ] = vspace / v_axes
0 commit comments