@@ -361,15 +361,19 @@ def do_constrained_layout(fig, renderer, h_pad, w_pad,
361
361
'bottom' )
362
362
363
363
###########
364
- # Now we make the widths and heights similar.
364
+ # Now we make the widths and heights of position boxes
365
+ # similar. (i.e the spine locations)
365
366
# This allows vertically stacked subplots to have
366
- # different sizes if they occupy different ammounts
367
+ # different sizes if they occupy different amounts
367
368
# of the gridspec: i.e.
368
369
# gs = gridspec.GridSpec(3,1)
369
370
# ax1 = gs[0,:]
370
371
# ax2 = gs[1:,:]
371
372
# then drows0 = 1, and drowsC = 2, and ax2
372
373
# should be at least twice as large as ax1.
374
+ # But it can be more than twice as large because
375
+ # it needs less room for the labeling.
376
+ #
373
377
# For height, this only needs to be done if the
374
378
# subplots share a column. For width if they
375
379
# share a row.
@@ -387,31 +391,41 @@ def do_constrained_layout(fig, renderer, h_pad, w_pad,
387
391
dcolsC = (colnumCmax - colnumCmin + 1 )
388
392
dcols0 = (colnum0max - colnum0min + 1 )
389
393
390
- if drowsC > drows0 :
394
+ if height0 > heightC :
391
395
if in_same_column (ss0 , ssc ):
392
396
ax ._poslayoutbox .constrain_height_min (
393
- axc ._poslayoutbox .height * drows0 * height0
394
- / drowsC / heightC )
395
- elif drowsC < drows0 :
396
- if in_same_column (ss0 , ssc ):
397
+ axc ._poslayoutbox .height * height0 / heightC )
398
+ # these constraints stop the smaller axes from
399
+ # being allowed to go to zero height...
397
400
axc ._poslayoutbox .constrain_height_min (
398
- ax ._poslayoutbox .height * drowsC * heightC
399
- / drows0 / drowsC )
401
+ ax ._poslayoutbox .height * heightC /
402
+ ( height0 * 1.8 ) )
400
403
else :
404
+ if in_same_column (ss0 , ssc ):
405
+ axc ._poslayoutbox .constrain_height_min (
406
+ ax ._poslayoutbox .height * heightC / height0 )
407
+ ax ._poslayoutbox .constrain_height_min (
408
+ ax ._poslayoutbox .height * height0 /
409
+ (heightC * 1.8 ))
410
+ if drows0 == drowsC :
401
411
ax ._poslayoutbox .constrain_height (
402
412
axc ._poslayoutbox .height * height0 / heightC )
403
413
# widths...
404
- if dcolsC > dcols0 :
414
+ if width0 > widthC :
405
415
if in_same_row (ss0 , ssc ):
406
416
ax ._poslayoutbox .constrain_width_min (
407
- axc ._poslayoutbox .width * dcols0 * width0
408
- / dcolsC / widthC )
409
- elif dcolsC < dcols0 :
410
- if in_same_row (ss0 , ssc ):
417
+ axc ._poslayoutbox .width * width0 / widthC )
411
418
axc ._poslayoutbox .constrain_width_min (
412
- ax ._poslayoutbox .width * dcolsC * widthC
413
- / dcols0 / width0 )
419
+ ax ._poslayoutbox .width * widthC /
420
+ ( width0 * 1.8 ) )
414
421
else :
422
+ if in_same_row (ss0 , ssc ):
423
+ axc ._poslayoutbox .constrain_width_min (
424
+ ax ._poslayoutbox .width * widthC / width0 )
425
+ ax ._poslayoutbox .constrain_width_min (
426
+ axc ._poslayoutbox .width * width0 /
427
+ (widthC * 1.8 ))
428
+ if dcols0 == dcolsC :
415
429
ax ._poslayoutbox .constrain_width (
416
430
axc ._poslayoutbox .width * width0 / widthC )
417
431
0 commit comments