@@ -277,31 +277,34 @@ def _make_layout_margins(fig, renderer, *, w_pad=0, h_pad=0,
277
277
def _make_margin_suptitles (fig , renderer , * , w_pad = 0 , h_pad = 0 ):
278
278
# Figure out how large the suptitle is and make the
279
279
# top level figure margin larger.
280
-
280
+
281
281
invTransFig = fig .transFigure .inverted ().transform_bbox
282
- padboxF = mtransforms .Bbox ([[0 , 0 ], [w_pad , h_pad ]])
283
- padboxLocal = (fig .transFigure - fig .transSubfigure ).transform_bbox (padboxF )
284
- h_padLocal = padboxLocal .height
285
- w_padLocal = padboxLocal .width
282
+ # get the h_pad and w_pad as distances in the local subfigure coordinates:
283
+ padbox = mtransforms .Bbox ([[0 , 0 ], [w_pad , h_pad ]])
284
+ padbox = (fig .transFigure -
285
+ fig .transSubfigure ).transform_bbox (padbox )
286
+ h_pad_local = padbox .height
287
+ w_pad_local = padbox .width
286
288
287
289
for panel in fig .subfigs :
288
290
_make_margin_suptitles (panel , renderer , w_pad = w_pad , h_pad = h_pad )
289
291
290
292
if fig ._suptitle is not None and fig ._suptitle .get_in_layout ():
291
293
p = fig ._suptitle .get_position ()
292
- fig ._suptitle .set_position ((p [0 ], 1 - h_padLocal ))
293
- bbox = invTransFig (fig ._suptitle .get_tightbbox (renderer )) # fig coords
294
+ fig ._suptitle .set_position ((p [0 ], 1 - h_pad_local ))
295
+ bbox = invTransFig (fig ._suptitle .get_tightbbox (renderer )) # fig coords
294
296
fig ._layoutgrid .edit_margin_min ('top' , bbox .height + 2.0 * h_pad )
295
297
296
298
if fig ._supxlabel is not None and fig ._supxlabel .get_in_layout ():
297
299
p = fig ._supxlabel .get_position ()
298
- fig ._supxlabel .set_position ((p [0 ], h_padLocal ))
300
+ fig ._supxlabel .set_position ((p [0 ], h_pad_local ))
301
+ bbox = invTransFig (fig ._supxlabel .get_tightbbox (renderer )) # fig coord
299
302
fig ._layoutgrid .edit_margin_min ('bottom' , bbox .height + 2 * h_pad )
300
303
301
304
if fig ._supylabel is not None and fig ._supxlabel .get_in_layout ():
302
305
p = fig ._supylabel .get_position ()
303
- fig ._supylabel .set_position ((w_padLocal , p [1 ]))
304
- bbox = invTransFig (fig ._supylabel .get_tightbbox (renderer )) # fig coords
306
+ fig ._supylabel .set_position ((w_pad_local , p [1 ]))
307
+ bbox = invTransFig (fig ._supylabel .get_tightbbox (renderer )) # fig coord
305
308
fig ._layoutgrid .edit_margin_min ('left' , bbox .width + 2 * w_pad )
306
309
307
310
0 commit comments