Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3ed1397

Browse files
committed
Merge pull request #1136 from pwuertz/tight-layout-parameters
Configuring automatic use of tight_layout
2 parents e528dad + 8eb05dc commit 3ed1397

File tree

5 files changed

+536
-6
lines changed

5 files changed

+536
-6
lines changed

lib/matplotlib/figure.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,11 @@ def __init__(self,
287287
288288
*tight_layout*
289289
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``.
292295
"""
293296
Artist.__init__(self)
294297

@@ -393,12 +396,16 @@ def set_tight_layout(self, tight):
393396
Set whether :meth:`tight_layout` is used upon drawing.
394397
If None, the rcParams['figure.autolayout'] value will be set.
395398
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 ]
397404
"""
398405
if tight is None:
399406
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 {}
402409

403410
def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right'):
404411
"""
@@ -956,7 +963,7 @@ def draw(self, renderer):
956963

957964
if self.get_tight_layout() and self.axes:
958965
try:
959-
self.tight_layout(renderer)
966+
self.tight_layout(renderer, **self._tight_parameters)
960967
except ValueError:
961968
pass
962969
# ValueError can occur when resizing a window.
Binary file not shown.

0 commit comments

Comments
 (0)