From 29f76219170f19da69d862208bc098a8539fdef3 Mon Sep 17 00:00:00 2001 From: Jae-Joon Lee Date: Wed, 28 Jun 2023 01:49:10 +0900 Subject: [PATCH] TightLayoutEngine.execute runs get_tight_layout_figure twice --- lib/matplotlib/layout_engine.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/layout_engine.py b/lib/matplotlib/layout_engine.py index d751059f4e09..29a2e24e4535 100644 --- a/lib/matplotlib/layout_engine.py +++ b/lib/matplotlib/layout_engine.py @@ -180,12 +180,13 @@ def execute(self, fig): info = self._params renderer = fig._get_renderer() with getattr(renderer, "_draw_disabled", nullcontext)(): - kwargs = get_tight_layout_figure( - fig, fig.axes, get_subplotspec_list(fig.axes), renderer, - pad=info['pad'], h_pad=info['h_pad'], w_pad=info['w_pad'], - rect=info['rect']) - if kwargs: - fig.subplots_adjust(**kwargs) + for _ in range(2): + kwargs = get_tight_layout_figure( + fig, fig.axes, get_subplotspec_list(fig.axes), renderer, + pad=info['pad'], h_pad=info['h_pad'], w_pad=info['w_pad'], + rect=info['rect']) + if kwargs: + fig.subplots_adjust(**kwargs) def set(self, *, pad=None, w_pad=None, h_pad=None, rect=None): """