@@ -2406,40 +2406,43 @@ def set_constrained_layout(self, constrained):
2406
2406
2407
2407
self .stale = True
2408
2408
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 ):
2410
2411
"""
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)``.
2413
2416
2414
2417
See :doc:`/tutorials/intermediate/constrainedlayout_guide`.
2415
2418
2416
2419
Parameters
2417
2420
----------
2418
- w_pad : float
2421
+ w_pad : float, default: :rc:`figure.constrained_layout.w_pad`
2419
2422
Width padding in inches. This is the pad around Axes
2420
2423
and is meant to make sure there is enough room for fonts to
2421
2424
look good. Defaults to 3 pts = 0.04167 inches
2422
2425
2423
- h_pad : float
2426
+ h_pad : float, default: :rc:`figure.constrained_layout.h_pad`
2424
2427
Height padding in inches. Defaults to 3 pts.
2425
2428
2426
- wspace : float
2429
+ wspace : float, default: :rc:`figure.constrained_layout.wspace`
2427
2430
Width padding between subplots, expressed as a fraction of the
2428
2431
subplot width. The total padding ends up being w_pad + wspace.
2429
2432
2430
- hspace : float
2433
+ hspace : float, default: :rc:`figure.constrained_layout.hspace`
2431
2434
Height padding between subplots, expressed as a fraction of the
2432
2435
subplot width. The total padding ends up being h_pad + hspace.
2433
2436
2434
2437
"""
2435
2438
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
2440
2443
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 } ' ])
2443
2446
2444
2447
def get_constrained_layout_pads (self , relative = False ):
2445
2448
"""
0 commit comments