From 83345978de0a17d1594f20ec55503abfcc084998 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 1 Nov 2022 21:57:33 -0400 Subject: [PATCH] Backport PR #24301: Restore get_renderer function in deprecated tight_layout --- lib/matplotlib/tight_layout.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index 00a5c4b672aa..233e96c0d47a 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -1,3 +1,13 @@ from matplotlib._tight_layout import * # noqa: F401, F403 from matplotlib import _api _api.warn_deprecated("3.6", name=__name__, obj_type="module") + + +@_api.deprecated("3.6", alternative="figure.canvas.get_renderer()") +def get_renderer(fig): + 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)