diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index 00a5c4b672aa..75bd5bd6c496 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -1,3 +1,16 @@ from matplotlib._tight_layout import * # noqa: F401, F403 from matplotlib import _api _api.warn_deprecated("3.6", name=__name__, obj_type="module") + + +# To be removed with the module +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)