@@ -403,9 +403,25 @@ def _align_spines(fig, gs):
403403 if height0 > height1 :
404404 ax0 ._poslayoutbox .constrain_height_min (
405405 ax1 ._poslayoutbox .height * height0 / height1 )
406+ # the precise constraint must be weak because
407+ # we may have one col with two axes, and the other
408+ # column with just one, and we want the top and
409+ # bottom of the short axes to align with the large one,
410+ # so the height of the long one is greater than
411+ # twice the height of the small ones. OTOH, if the
412+ # axes are not so constrained, we would like the pos
413+ # boxes to be the proper relative widths.
414+ # See test_constrained_layout17 fo
415+ ax0 ._poslayoutbox .constrain_height (
416+ ax1 ._poslayoutbox .height * height0 / height1 ,
417+ strength = 'weak' )
406418 elif height0 < height1 :
407419 ax1 ._poslayoutbox .constrain_height_min (
408420 ax0 ._poslayoutbox .height * height1 / height0 )
421+ # see above
422+ ax1 ._poslayoutbox .constrain_height (
423+ ax0 ._poslayoutbox .height * height1 / height0 ,
424+ strength = 'weak' )
409425 # For widths, do it if the subplots share a row.
410426 if not alignwidth and len (colspan0 ) == len (colspan1 ):
411427 ax0 ._poslayoutbox .constrain_width (
@@ -415,9 +431,17 @@ def _align_spines(fig, gs):
415431 if width0 > width1 :
416432 ax0 ._poslayoutbox .constrain_width_min (
417433 ax1 ._poslayoutbox .width * width0 / width1 )
434+ # see comment above
435+ ax0 ._poslayoutbox .constrain_width (
436+ ax1 ._poslayoutbox .width * width0 / width1 ,
437+ strength = 'weak' )
418438 elif width0 < width1 :
419439 ax1 ._poslayoutbox .constrain_width_min (
420440 ax0 ._poslayoutbox .width * width1 / width0 )
441+ # see comment above
442+ ax1 ._poslayoutbox .constrain_width_min (
443+ ax0 ._poslayoutbox .width * width1 / width0 ,
444+ strength = 'weak' )
421445
422446
423447def _arrange_subplotspecs (gs , hspace = 0 , wspace = 0 ):
0 commit comments