Emit "axes not compatible with tight_layout" in a single place. by anntzer · Pull Request #24343 · matplotlib/matplotlib · GitHub
Skip to content
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
5 changes: 4 additions & 1 deletion lib/matplotlib/_tight_layout.py
6 changes: 0 additions & 6 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3424,12 +3424,6 @@ def tight_layout(self, *, pad=1.08, h_pad=None, w_pad=None, rect=None):
.Figure.set_layout_engine
.pyplot.tight_layout
"""
from ._tight_layout import get_subplotspec_list
subplotspec_list = get_subplotspec_list(self.axes)
if None in subplotspec_list:
_api.warn_external("This figure includes Axes that are not "
"compatible with tight_layout, so results "
"might be incorrect.")
# note that here we do not permanently set the figures engine to
# tight_layout but rather just perform the layout in place and remove
# any previous engines.
Expand Down
14 changes: 3 additions & 11 deletions lib/matplotlib/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,20 +467,12 @@ def tight_layout(self, figure, renderer=None,
coordinates that the whole subplots area (including labels) will
fit into. Default (None) is the whole figure.
"""

subplotspec_list = _tight_layout.get_subplotspec_list(
figure.axes, grid_spec=self)
if None in subplotspec_list:
_api.warn_external("This figure includes Axes that are not "
"compatible with tight_layout, so results "
"might be incorrect.")

if renderer is None:
renderer = figure._get_renderer()

kwargs = _tight_layout.get_tight_layout_figure(
figure, figure.axes, subplotspec_list, renderer,
pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
figure, figure.axes,
_tight_layout.get_subplotspec_list(figure.axes, grid_spec=self),
renderer, pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
if kwargs:
self.update(**kwargs)

Expand Down
8 changes: 1 addition & 7 deletions lib/matplotlib/layout_engine.py