@@ -2406,40 +2406,43 @@ def set_constrained_layout(self, constrained):
24062406
24072407 self .stale = True
24082408
2409- def set_constrained_layout_pads (self , ** kwargs ):
2409+ def set_constrained_layout_pads (self , * , w_pad = None , h_pad = None ,
2410+ wspace = None , hspace = None ):
24102411 """
2411- Set padding for ``constrained_layout``. Note the kwargs can be passed
2412- as a dictionary ``fig.set_constrained_layout(**paddict)``.
2412+ Set padding for ``constrained_layout``.
2413+
2414+ Tip: The parameters can be passed from a dictionary by using
2415+ ``fig.set_constrained_layout(**pad_dict)``.
24132416
24142417 See :doc:`/tutorials/intermediate/constrainedlayout_guide`.
24152418
24162419 Parameters
24172420 ----------
2418- w_pad : float
2421+ w_pad : float, default: :rc:`figure.constrained_layout.w_pad`
24192422 Width padding in inches. This is the pad around Axes
24202423 and is meant to make sure there is enough room for fonts to
24212424 look good. Defaults to 3 pts = 0.04167 inches
24222425
2423- h_pad : float
2426+ h_pad : float, default: :rc:`figure.constrained_layout.h_pad`
24242427 Height padding in inches. Defaults to 3 pts.
24252428
2426- wspace : float
2429+ wspace : float, default: :rc:`figure.constrained_layout.wspace`
24272430 Width padding between subplots, expressed as a fraction of the
24282431 subplot width. The total padding ends up being w_pad + wspace.
24292432
2430- hspace : float
2433+ hspace : float, default: :rc:`figure.constrained_layout.hspace`
24312434 Height padding between subplots, expressed as a fraction of the
24322435 subplot width. The total padding ends up being h_pad + hspace.
24332436
24342437 """
24352438
2436- todo = ['w_pad' , 'h_pad' , 'wspace' , 'hspace' ]
2437- for td in todo :
2438- if td in kwargs and kwargs [ td ] is not None :
2439- self ._constrained_layout_pads [td ] = kwargs [ td ]
2439+ for name , size in zip ( ['w_pad' , 'h_pad' , 'wspace' , 'hspace' ],
2440+ [ w_pad , h_pad , wspace , hspace ]) :
2441+ if size is not None :
2442+ self ._constrained_layout_pads [name ] = size
24402443 else :
2441- self ._constrained_layout_pads [td ] = (
2442- mpl .rcParams ['figure.constrained_layout.' + td ])
2444+ self ._constrained_layout_pads [name ] = (
2445+ mpl .rcParams [f 'figure.constrained_layout.{ name } ' ])
24432446
24442447 def get_constrained_layout_pads (self , relative = False ):
24452448 """
0 commit comments