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

Skip to content

fixed conversion from pt to inch in tight_layout #1065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_tightlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

10 changes: 5 additions & 5 deletions lib/matplotlib/tight_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down