Skip to content

fixed issue #5456 #6167

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

Closed
wants to merge 3 commits into from
Closed
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
15 changes: 15 additions & 0 deletions lib/matplotlib/tight_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,34 @@ def auto_adjust_subplotpars(fig, renderer,
if not margin_left:
margin_left = max([sum(s) for s in hspaces[::cols + 1]] + [0])
margin_left += pad_inches / fig_width_inch
# bugfix for bug-#5456
# simple check for the error
if margin_left > 0.5:
margin_left = 0.05
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these magic numbers? It might be more reliable to do a check for the actual fail condition (margin_left > 1 - margin_right) at the end and fix it there once you know all of the margins.


if not margin_right:
margin_right = max([sum(s) for s in hspaces[cols::cols + 1]] + [0])
margin_right += pad_inches / fig_width_inch
# bugfix for bug-#5456
# simple check for the error
if margin_right > 0.5:
margin_right = 0.05

if not margin_top:
margin_top = max([sum(s) for s in vspaces[:cols]] + [0])
margin_top += pad_inches / fig_height_inch
# bugfix for bug-#5456
if margin_top > 0.5:
margin_top = 0.05

if not margin_bottom:
margin_bottom = max([sum(s) for s in vspaces[-cols:]] + [0])
margin_bottom += pad_inches / fig_height_inch

# bugfix for bug-#5456
if margin_bottom > 0.5:
margin_bottom = 0.05

kwargs = dict(left=margin_left,
right=1 - margin_right,
bottom=margin_bottom,
Expand Down