1818import numpy as np
1919
2020from matplotlib import _api , artist as martist
21- from matplotlib ._tight_layout import get_renderer
2221import matplotlib .transforms as mtransforms
2322import matplotlib ._layoutgrid as mlayoutgrid
2423
@@ -74,8 +73,6 @@ def do_constrained_layout(fig, h_pad, w_pad,
7473 fig : Figure
7574 ``Figure`` instance to do the layout in.
7675
77- renderer : Renderer
78- Renderer to use.
7976
8077 h_pad, w_pad : float
8178 Padding around the axes elements in figure-normalized units.
@@ -92,7 +89,6 @@ def do_constrained_layout(fig, h_pad, w_pad,
9289 layoutgrid : private debugging structure
9390 """
9491
95- renderer = get_renderer (fig )
9692 # make layoutgrid tree...
9793 layoutgrids = make_layoutgrids (fig , None )
9894 if not layoutgrids ['hasgrids' ]:
@@ -109,9 +105,9 @@ def do_constrained_layout(fig, h_pad, w_pad,
109105
110106 # make margins for all the axes and subfigures in the
111107 # figure. Add margins for colorbars...
112- make_layout_margins (layoutgrids , fig , renderer , h_pad = h_pad ,
108+ make_layout_margins (layoutgrids , fig , h_pad = h_pad ,
113109 w_pad = w_pad , hspace = hspace , wspace = wspace )
114- make_margin_suptitles (layoutgrids , fig , renderer , h_pad = h_pad ,
110+ make_margin_suptitles (layoutgrids , fig , h_pad = h_pad ,
115111 w_pad = w_pad )
116112
117113 # if a layout is such that a columns (or rows) margin has no
@@ -123,7 +119,7 @@ def do_constrained_layout(fig, h_pad, w_pad,
123119 layoutgrids [fig ].update_variables ()
124120
125121 if check_no_collapsed_axes (layoutgrids , fig ):
126- reposition_axes (layoutgrids , fig , renderer , h_pad = h_pad ,
122+ reposition_axes (layoutgrids , fig , h_pad = h_pad ,
127123 w_pad = w_pad , hspace = hspace , wspace = wspace )
128124 else :
129125 _api .warn_external ('constrained_layout not applied because '
@@ -283,7 +279,7 @@ def get_margin_from_padding(obj, *, w_pad=0, h_pad=0,
283279 return margin
284280
285281
286- def make_layout_margins (layoutgrids , fig , renderer , * , w_pad = 0 , h_pad = 0 ,
282+ def make_layout_margins (layoutgrids , fig , * , w_pad = 0 , h_pad = 0 ,
287283 hspace = 0 , wspace = 0 ):
288284 """
289285 For each axes, make a margin between the *pos* layoutbox and the
@@ -294,7 +290,7 @@ def make_layout_margins(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0,
294290 """
295291 for sfig in fig .subfigs : # recursively make child panel margins
296292 ss = sfig ._subplotspec
297- make_layout_margins (layoutgrids , sfig , renderer ,
293+ make_layout_margins (layoutgrids , sfig ,
298294 w_pad = w_pad , h_pad = h_pad ,
299295 hspace = hspace , wspace = wspace )
300296
@@ -314,7 +310,7 @@ def make_layout_margins(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0,
314310
315311 margin = get_margin_from_padding (ax , w_pad = w_pad , h_pad = h_pad ,
316312 hspace = hspace , wspace = wspace )
317- pos , bbox = get_pos_and_bbox (ax , renderer )
313+ pos , bbox = get_pos_and_bbox (ax )
318314 # the margin is the distance between the bounding box of the axes
319315 # and its position (plus the padding from above)
320316 margin ['left' ] += pos .x0 - bbox .x0
@@ -331,7 +327,7 @@ def make_layout_margins(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0,
331327 # colorbars can be child of more than one subplot spec:
332328 cbp_rspan , cbp_cspan = get_cb_parent_spans (cbax )
333329 loc = cbax ._colorbar_info ['location' ]
334- cbpos , cbbbox = get_pos_and_bbox (cbax , renderer )
330+ cbpos , cbbbox = get_pos_and_bbox (cbax )
335331 if loc == 'right' :
336332 if cbp_cspan .stop == ss .colspan .stop :
337333 # only increase if the colorbar is on the right edge
@@ -367,7 +363,7 @@ def make_layout_margins(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0,
367363 layoutgrids [gs ].edit_outer_margin_mins (margin , ss )
368364
369365
370- def make_margin_suptitles (layoutgrids , fig , renderer , * , w_pad = 0 , h_pad = 0 ):
366+ def make_margin_suptitles (layoutgrids , fig , * , w_pad = 0 , h_pad = 0 ):
371367 # Figure out how large the suptitle is and make the
372368 # top level figure margin larger.
373369
@@ -380,29 +376,29 @@ def make_margin_suptitles(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0):
380376 w_pad_local = padbox .width
381377
382378 for sfig in fig .subfigs :
383- make_margin_suptitles (layoutgrids , sfig , renderer ,
379+ make_margin_suptitles (layoutgrids , sfig ,
384380 w_pad = w_pad , h_pad = h_pad )
385381
386382 if fig ._suptitle is not None and fig ._suptitle .get_in_layout ():
387383 p = fig ._suptitle .get_position ()
388384 if getattr (fig ._suptitle , '_autopos' , False ):
389385 fig ._suptitle .set_position ((p [0 ], 1 - h_pad_local ))
390- bbox = inv_trans_fig (fig ._suptitle .get_tightbbox (renderer ))
386+ bbox = inv_trans_fig (fig ._suptitle .get_tightbbox ())
391387 layoutgrids [fig ].edit_margin_min ('top' , bbox .height + 2 * h_pad )
392388
393389 if fig ._supxlabel is not None and fig ._supxlabel .get_in_layout ():
394390 p = fig ._supxlabel .get_position ()
395391 if getattr (fig ._supxlabel , '_autopos' , False ):
396392 fig ._supxlabel .set_position ((p [0 ], h_pad_local ))
397- bbox = inv_trans_fig (fig ._supxlabel .get_tightbbox (renderer ))
393+ bbox = inv_trans_fig (fig ._supxlabel .get_tightbbox ())
398394 layoutgrids [fig ].edit_margin_min ('bottom' ,
399395 bbox .height + 2 * h_pad )
400396
401397 if fig ._supylabel is not None and fig ._supylabel .get_in_layout ():
402398 p = fig ._supylabel .get_position ()
403399 if getattr (fig ._supylabel , '_autopos' , False ):
404400 fig ._supylabel .set_position ((w_pad_local , p [1 ]))
405- bbox = inv_trans_fig (fig ._supylabel .get_tightbbox (renderer ))
401+ bbox = inv_trans_fig (fig ._supylabel .get_tightbbox ())
406402 layoutgrids [fig ].edit_margin_min ('left' , bbox .width + 2 * w_pad )
407403
408404
@@ -523,14 +519,14 @@ def get_cb_parent_spans(cbax):
523519 return rowspan , colspan
524520
525521
526- def get_pos_and_bbox (ax , renderer ):
522+ def get_pos_and_bbox (ax ):
527523 """
528524 Get the position and the bbox for the axes.
529525
530526 Parameters
531527 ----------
532528 ax
533- renderer
529+
534530
535531 Returns
536532 -------
@@ -543,15 +539,15 @@ def get_pos_and_bbox(ax, renderer):
543539 pos = ax .get_position (original = True )
544540 # pos is in panel co-ords, but we need in figure for the layout
545541 pos = pos .transformed (fig .transSubfigure - fig .transFigure )
546- tightbbox = martist ._get_tightbbox_for_layout_only (ax , renderer )
542+ tightbbox = martist ._get_tightbbox_for_layout_only (ax )
547543 if tightbbox is None :
548544 bbox = pos
549545 else :
550546 bbox = tightbbox .transformed (fig .transFigure .inverted ())
551547 return pos , bbox
552548
553549
554- def reposition_axes (layoutgrids , fig , renderer , * ,
550+ def reposition_axes (layoutgrids , fig , * ,
555551 w_pad = 0 , h_pad = 0 , hspace = 0 , wspace = 0 ):
556552 """
557553 Reposition all the axes based on the new inner bounding box.
@@ -561,7 +557,7 @@ def reposition_axes(layoutgrids, fig, renderer, *,
561557 bbox = layoutgrids [sfig ].get_outer_bbox ()
562558 sfig ._redo_transform_rel_fig (
563559 bbox = bbox .transformed (trans_fig_to_subfig ))
564- reposition_axes (layoutgrids , sfig , renderer ,
560+ reposition_axes (layoutgrids , sfig ,
565561 w_pad = w_pad , h_pad = h_pad ,
566562 wspace = wspace , hspace = hspace )
567563
@@ -589,11 +585,11 @@ def reposition_axes(layoutgrids, fig, renderer, *,
589585 offset = {'left' : 0 , 'right' : 0 , 'bottom' : 0 , 'top' : 0 }
590586 for nn , cbax in enumerate (ax ._colorbars [::- 1 ]):
591587 if ax == cbax ._colorbar_info ['parents' ][0 ]:
592- reposition_colorbar (layoutgrids , cbax , renderer ,
588+ reposition_colorbar (layoutgrids , cbax ,
593589 offset = offset )
594590
595591
596- def reposition_colorbar (layoutgrids , cbax , renderer , * , offset = None ):
592+ def reposition_colorbar (layoutgrids , cbax , * , offset = None ):
597593 """
598594 Place the colorbar in its new place.
599595
@@ -602,7 +598,6 @@ def reposition_colorbar(layoutgrids, cbax, renderer, *, offset=None):
602598 cbax : Axes
603599 Axes for the colorbar
604600
605- renderer :
606601 w_pad, h_pad : float
607602 width and height padding (in fraction of figure)
608603 hspace, wspace : float
@@ -629,7 +624,7 @@ def reposition_colorbar(layoutgrids, cbax, renderer, *, offset=None):
629624 aspect = cbax ._colorbar_info ['aspect' ]
630625 shrink = cbax ._colorbar_info ['shrink' ]
631626
632- cbpos , cbbbox = get_pos_and_bbox (cbax , renderer )
627+ cbpos , cbbbox = get_pos_and_bbox (cbax )
633628
634629 # Colorbar gets put at extreme edge of outer bbox of the subplotspec
635630 # It needs to be moved in by: 1) a pad 2) its "margin" 3) by
0 commit comments