@@ -287,8 +287,11 @@ def __init__(self,
287
287
288
288
*tight_layout*
289
289
If *False* use *subplotpars*; if *True* adjust subplot
290
- parameters using :meth:`tight_layout`. Defaults to
291
- rc ``figure.autolayout``.
290
+ parameters using :meth:`tight_layout` with default padding.
291
+ When providing a dict containing the keys `pad`, `w_pad`, `h_pad`
292
+ and `rect`, the default :meth:`tight_layout` paddings will be
293
+ overridden.
294
+ Defaults to rc ``figure.autolayout``.
292
295
"""
293
296
Artist .__init__ (self )
294
297
@@ -393,12 +396,16 @@ def set_tight_layout(self, tight):
393
396
Set whether :meth:`tight_layout` is used upon drawing.
394
397
If None, the rcParams['figure.autolayout'] value will be set.
395
398
396
- ACCEPTS: [True | False | None]
399
+ When providing a dict containing the keys `pad`, `w_pad`, `h_pad`
400
+ and `rect`, the default :meth:`tight_layout` paddings will be
401
+ overridden.
402
+
403
+ ACCEPTS: [True | False | dict | None ]
397
404
"""
398
405
if tight is None :
399
406
tight = rcParams ['figure.autolayout' ]
400
- tight = bool (tight )
401
- self ._tight = tight
407
+ self . _tight = bool (tight )
408
+ self ._tight_parameters = tight if isinstance ( tight , dict ) else {}
402
409
403
410
def autofmt_xdate (self , bottom = 0.2 , rotation = 30 , ha = 'right' ):
404
411
"""
@@ -956,7 +963,7 @@ def draw(self, renderer):
956
963
957
964
if self .get_tight_layout () and self .axes :
958
965
try :
959
- self .tight_layout (renderer )
966
+ self .tight_layout (renderer , ** self . _tight_parameters )
960
967
except ValueError :
961
968
pass
962
969
# ValueError can occur when resizing a window.
0 commit comments