From d7df7906ddaf0ae2e46990967a9aa1c77a2dfda7 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Fri, 8 Nov 2024 08:37:40 +0000 Subject: [PATCH] Use improved syntax for matplotlib >= 3.10 --- matplotlib_inline/backend_inline.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/matplotlib_inline/backend_inline.py b/matplotlib_inline/backend_inline.py index b5c911c..90a331c 100644 --- a/matplotlib_inline/backend_inline.py +++ b/matplotlib_inline/backend_inline.py @@ -208,9 +208,14 @@ def configure_inline_support(shell, backend): def _enable_matplotlib_integration(): """Enable extra IPython matplotlib integration when we are loaded as the matplotlib backend.""" - from matplotlib import rcParams ip = get_ipython() - backend = rcParams._get("backend") + + import matplotlib + if matplotlib.__version_info__ >= (3, 10): + backend = matplotlib.get_backend(auto_select=False) + else: + backend = matplotlib.rcParams._get("backend") + if ip and backend in ('inline', 'module://matplotlib_inline.backend_inline'): from IPython.core.pylabtools import activate_matplotlib try: