From f0cc16cba9c7a9afaebbfccda236e6a5da23a568 Mon Sep 17 00:00:00 2001 From: Connor Brooks Date: Mon, 1 Oct 2018 21:03:56 -0400 Subject: [PATCH 1/4] added tight_layout padding rcParam added rc parameters for tight_layout padding --- lib/matplotlib/rcsetup.py | 5 +++++ lib/matplotlib/tight_layout.py | 2 +- matplotlibrc.template | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 4933bd0bd8ea..456fe2a1b059 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1349,6 +1349,11 @@ def _validate_linestyle(ls): 'figure.constrained_layout.h_pad': [0.04167, validate_float], 'figure.constrained_layout.w_pad': [0.04167, validate_float], + ##Figure tight_layout + 'figure.tight_layout.pad': [1.08, validate_float], + 'figure.tight_layout.h_pad': [None, validate_float], + 'figure.tight_layout.w_pad': [None, validate_float], + ## Saving figure's properties 'savefig.dpi': ['figure', validate_dpi], # DPI 'savefig.facecolor': ['white', validate_color], diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index 344413cc9b7e..4f27086a94fd 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -36,7 +36,7 @@ def _get_top(tight_bbox, axes_bbox): def auto_adjust_subplotpars( fig, renderer, nrows_ncols, num1num2_list, subplot_list, - ax_bbox_list=None, pad=1.08, h_pad=None, w_pad=None, rect=None): + ax_bbox_list=None, pad=rcParams['figure.tight_layout.pad'], h_pad=rcParams['figure.tight_layout.h_pad'], w_pad=rcParams['figure.tight_layout.wpad'], rect=None): """ Return a dict of subplot parameters to adjust spacing between subplots. diff --git a/matplotlibrc.template b/matplotlibrc.template index 9ce42e460f58..c295358205ba 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -450,6 +450,9 @@ #figure.autolayout : False ## When True, automatically adjust subplot ## parameters to make the plot fit the figure ## using `tight_layout` +#figure.tight_layout.pad : 1.08 ## padding between the figure edge and subplots +#figure.tight_layout.h_pad : None ## padding height between edges of subplots +#figure.tight_layout.w_pad : None ## padding width between edges of subplots #figure.constrained_layout.use: False ## When True, automatically make plot ## elements fit on the figure. (Not compatible ## with `autolayout`, above). From c6fe57ba47133fcacfa21df426c4309f47151d50 Mon Sep 17 00:00:00 2001 From: Connor Brooks Date: Mon, 1 Oct 2018 21:55:28 -0400 Subject: [PATCH 2/4] added rc parameters for tight_layout padding --- lib/matplotlib/tight_layout.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index 4f27086a94fd..a545beaa7579 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -36,7 +36,8 @@ def _get_top(tight_bbox, axes_bbox): def auto_adjust_subplotpars( fig, renderer, nrows_ncols, num1num2_list, subplot_list, - ax_bbox_list=None, pad=rcParams['figure.tight_layout.pad'], h_pad=rcParams['figure.tight_layout.h_pad'], w_pad=rcParams['figure.tight_layout.wpad'], rect=None): + ax_bbox_list=None, pad=rcParams['figure.tight_layout.pad'], + h_pad=rcParams['figure.tight_layout.h_pad'], w_pad=rcParams['figure.tight_layout.wpad'], rect=None): """ Return a dict of subplot parameters to adjust spacing between subplots. @@ -266,7 +267,8 @@ def get_subplotspec_list(axes_list, grid_spec=None): def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, - pad=1.08, h_pad=None, w_pad=None, rect=None): + pad=rcParams['figure.tight_layout.pad'], h_pad=rcParams['figure.tight_layout.h_pad'], + w_pad=rcParams['figure.tight_layout.wpad'], rect=None): """ Return subplot parameters for tight-layouted-figure with specified padding. From 76ad1cbe182812e63701aa452804086b27d84002 Mon Sep 17 00:00:00 2001 From: Connor Brooks Date: Mon, 1 Oct 2018 21:55:28 -0400 Subject: [PATCH 3/4] added rc parameters for tight_layout padding --- lib/matplotlib/rcsetup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 456fe2a1b059..c9c97a0921db 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1351,8 +1351,8 @@ def _validate_linestyle(ls): ##Figure tight_layout 'figure.tight_layout.pad': [1.08, validate_float], - 'figure.tight_layout.h_pad': [None, validate_float], - 'figure.tight_layout.w_pad': [None, validate_float], + 'figure.tight_layout.h_pad': [None, validate_float_or_None], + 'figure.tight_layout.w_pad': [None, validate_float_or_None], ## Saving figure's properties 'savefig.dpi': ['figure', validate_dpi], # DPI From 0581e70de4cf5154eff12ac7db5942e3883aa4a7 Mon Sep 17 00:00:00 2001 From: Connor Brooks Date: Mon, 1 Oct 2018 21:55:28 -0400 Subject: [PATCH 4/4] added rc parameters for tight_layout padding --- lib/matplotlib/tight_layout.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index a545beaa7579..4023ecb8996e 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -37,7 +37,7 @@ def _get_top(tight_bbox, axes_bbox): def auto_adjust_subplotpars( fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list=None, pad=rcParams['figure.tight_layout.pad'], - h_pad=rcParams['figure.tight_layout.h_pad'], w_pad=rcParams['figure.tight_layout.wpad'], rect=None): + h_pad=rcParams['figure.tight_layout.h_pad'], w_pad=rcParams['figure.tight_layout.w_pad'], rect=None): """ Return a dict of subplot parameters to adjust spacing between subplots. @@ -268,7 +268,7 @@ def get_subplotspec_list(axes_list, grid_spec=None): def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad=rcParams['figure.tight_layout.pad'], h_pad=rcParams['figure.tight_layout.h_pad'], - w_pad=rcParams['figure.tight_layout.wpad'], rect=None): + w_pad=rcParams['figure.tight_layout.w_pad'], rect=None): """ Return subplot parameters for tight-layouted-figure with specified padding.