File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Original file line number Diff line number Diff line change @@ -171,25 +171,40 @@ def auto_adjust_subplotpars(
171
171
margin_bottom = max ([sum (s ) for s in vspaces [- cols :]] + [0 ])
172
172
margin_bottom += pad_inches / fig_height_inch
173
173
174
+ if margin_left + margin_right >= 1 :
175
+ margin_left = 0.4999
176
+ margin_right = 0.4999
177
+ warnings .warn ('The left and right margins cannot be made large '
178
+ 'enough to accomodate all axes decorations. ' )
174
179
kwargs = dict (left = margin_left ,
175
180
right = 1 - margin_right ,
176
181
bottom = margin_bottom ,
177
182
top = 1 - margin_top )
178
-
179
183
if cols > 1 :
180
184
hspace = (
181
185
max (sum (s )
182
186
for i in range (rows )
183
187
for s in hspaces [i * (cols + 1 ) + 1 :(i + 1 ) * (cols + 1 ) - 1 ])
184
188
+ hpad_inches / fig_width_inch )
189
+ # axes widths:
185
190
h_axes = (1 - margin_right - margin_left - hspace * (cols - 1 )) / cols
186
- kwargs ["wspace" ] = hspace / h_axes
191
+ if h_axes < 0. :
192
+ warnings .warn ('tight_layout cannot make axes width small enough '
193
+ 'to accomodate all axes decorations' )
194
+ kwargs ["wspace" ] = 0.5
195
+ else :
196
+ kwargs ["wspace" ] = hspace / h_axes
187
197
188
198
if rows > 1 :
189
199
vspace = (max (sum (s ) for s in vspaces [cols :- cols ])
190
200
+ vpad_inches / fig_height_inch )
191
201
v_axes = (1 - margin_top - margin_bottom - vspace * (rows - 1 )) / rows
192
- kwargs ["hspace" ] = vspace / v_axes
202
+ if v_axes < 0 :
203
+ warnings .warn ('tight_layout cannot make axes height small enough '
204
+ 'to accomodate all axes decorations' )
205
+ kwargs ["hspace" ] = 0.5
206
+ else :
207
+ kwargs ["hspace" ] = vspace / v_axes
193
208
194
209
return kwargs
195
210
You can’t perform that action at this time.
0 commit comments