Skip to content
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: 11 additions & 4 deletions lib/matplotlib/tight_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

import warnings

import numpy as np

import matplotlib
from matplotlib import rcParams
from matplotlib.transforms import TransformedBbox, Bbox

from matplotlib.font_manager import FontProperties
rcParams = matplotlib.rcParams


def _get_left(tight_bbox, axes_bbox):
Expand Down Expand Up @@ -193,13 +194,19 @@ def auto_adjust_subplotpars(fig, renderer,
for i in range(rows)
for s in hspaces[i * (cols + 1) + 1:(i + 1) * (cols + 1) - 1])
+ hpad_inches / fig_width_inch)
h_axes = (1 - margin_right - margin_left - hspace * (cols - 1)) / cols
# Make sure that `h_axes` (and, below, `v_axes`) stays positive, even
# when the axes are cramped.
h_axes = max(
(1 - margin_right - margin_left - hspace * (cols - 1)) / cols,
np.finfo(float).resolution)
kwargs["wspace"] = hspace / h_axes

if rows > 1:
vspace = (max(sum(s) for s in vspaces[cols:-cols])
+ vpad_inches / fig_height_inch)
v_axes = (1 - margin_top - margin_bottom - vspace * (rows - 1)) / rows
v_axes = max(
(1 - margin_top - margin_bottom - vspace * (rows - 1)) / rows,
np.finfo(float).resolution)
kwargs["hspace"] = vspace / v_axes

return kwargs
Expand Down