From 74093a61affb0b70ff0ca74a25fda5f1fc610200 Mon Sep 17 00:00:00 2001 From: pwuertz Date: Fri, 10 Aug 2012 11:00:02 +0200 Subject: [PATCH 1/2] fixed conversion from pt to inch in tight_layout --- lib/matplotlib/tight_layout.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index b1cca6b9e5a8..ea9e6739aece 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -71,15 +71,15 @@ def auto_adjust_subplotpars(fig, renderer, rows, cols = nrows_ncols - pad_inches = pad * FontProperties(size=rcParams["font.size"]).get_size_in_points() / renderer.dpi + pad_inches = pad * FontProperties(size=rcParams["font.size"]).get_size_in_points() / 72. if h_pad is not None: - vpad_inches = h_pad * FontProperties(size=rcParams["font.size"]).get_size_in_points() / renderer.dpi + vpad_inches = h_pad * FontProperties(size=rcParams["font.size"]).get_size_in_points() / 72. else: vpad_inches = pad_inches if w_pad is not None: - hpad_inches = w_pad * FontProperties(size=rcParams["font.size"]).get_size_in_points() / renderer.dpi + hpad_inches = w_pad * FontProperties(size=rcParams["font.size"]).get_size_in_points() / 72. else: hpad_inches = pad_inches From 754535bd7ff9c2637ca22dc4149636e95b352a8a Mon Sep 17 00:00:00 2001 From: pwuertz Date: Fri, 10 Aug 2012 17:00:43 +0200 Subject: [PATCH 2/2] restore previous tight_layout padding results by correcting the defaults --- lib/matplotlib/figure.py | 2 +- lib/matplotlib/gridspec.py | 2 +- lib/matplotlib/pyplot.py | 2 +- lib/matplotlib/tests/test_tightlayout.py | 4 ++-- lib/matplotlib/tight_layout.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 27a7f549a7fe..a9c0b3300f69 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1361,7 +1361,7 @@ def get_tightbbox(self, renderer): return bbox_inches - def tight_layout(self, renderer=None, pad=1.2, h_pad=None, w_pad=None, rect=None): + def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None, rect=None): """ Adjust subplot parameters to give specified padding. diff --git a/lib/matplotlib/gridspec.py b/lib/matplotlib/gridspec.py index 4476ee1830a9..d202af518b9b 100644 --- a/lib/matplotlib/gridspec.py +++ b/lib/matplotlib/gridspec.py @@ -270,7 +270,7 @@ def locally_modified_subplot_params(self): return [k for k in self._AllowedKeys if getattr(self, k)] - def tight_layout(self, fig, renderer=None, pad=1.2, h_pad=None, w_pad=None, rect=None): + def tight_layout(self, fig, renderer=None, pad=1.08, h_pad=None, w_pad=None, rect=None): """ Adjust subplot parameters to give specified padding. diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 596a5446d119..07541612f5bd 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1114,7 +1114,7 @@ def subplot_tool(targetfig=None): -def tight_layout(pad=1.2, h_pad=None, w_pad=None, rect=None): +def tight_layout(pad=1.08, h_pad=None, w_pad=None, rect=None): """ Adjust subplot parameters to give specified padding. diff --git a/lib/matplotlib/tests/test_tightlayout.py b/lib/matplotlib/tests/test_tightlayout.py index e0bdea662454..076205e9dec2 100644 --- a/lib/matplotlib/tests/test_tightlayout.py +++ b/lib/matplotlib/tests/test_tightlayout.py @@ -110,7 +110,7 @@ def test_tight_layout6(): ax.set_xlabel("x-label", fontsize=12) - gs2.tight_layout(fig, rect=[0.5, 0, 1, 1], h_pad=0.5) + gs2.tight_layout(fig, rect=[0.5, 0, 1, 1], h_pad=0.45) top = min(gs1.top, gs2.top) bottom = max(gs1.bottom, gs2.bottom) @@ -119,5 +119,5 @@ def test_tight_layout6(): 0.5, 1 - (gs1.top-top)]) gs2.tight_layout(fig, rect=[0.5, 0 + (bottom-gs2.bottom), None, 1 - (gs2.top-top)], - h_pad=0.5) + h_pad=0.45) diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index ea9e6739aece..5a39e3f483d5 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -38,7 +38,7 @@ def auto_adjust_subplotpars(fig, renderer, num1num2_list, subplot_list, ax_bbox_list=None, - pad=1.2, h_pad=None, w_pad=None, + pad=1.08, h_pad=None, w_pad=None, rect=None): """ Return a dictionary of subplot parameters so that spacing between @@ -210,7 +210,7 @@ def get_renderer(fig): def get_tight_layout_figure(fig, axes_list, renderer, - pad=1.2, h_pad=None, w_pad=None, rect=None): + pad=1.08, h_pad=None, w_pad=None, rect=None): """ return subplot parameters for tigh-layouted- figure with specified padding.