diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index 18a19370a092..3b2d6bb33030 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -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 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,