From 1fe0a1f37207b611c79b88c10d1cea57fbdf4026 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 29 Oct 2022 12:52:39 +0200 Subject: [PATCH] Restore get_rendered function in deprecated tight_layout --- lib/matplotlib/_tight_layout.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/matplotlib/_tight_layout.py b/lib/matplotlib/_tight_layout.py index 192c2dcfdcb9..d61f827613bf 100644 --- a/lib/matplotlib/_tight_layout.py +++ b/lib/matplotlib/_tight_layout.py @@ -338,3 +338,15 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, rect=(left, bottom, right, top)) return kwargs + + +def get_renderer(fig): + if fig._cachedRenderer: + return fig._cachedRenderer + else: + canvas = fig.canvas + if canvas and hasattr(canvas, "get_renderer"): + return canvas.get_renderer() + else: + from . import backend_bases + return backend_bases._get_renderer(fig)