Skip to content

Fix incompatibility with matplotlib 3.5.0-3.9.x - #70

Open
jwhiss wants to merge 2 commits into
ipython:mainfrom
jwhiss:bug/fix-version-compatibility
Open

jwhiss wants to merge 2 commits into
ipython:mainfrom
jwhiss:bug/fix-version-compatibility

Conversation

@jwhiss

@jwhiss jwhiss commented Sep 21, 2026

Copy link
Copy Markdown

Summary

This PR fixes #54 and the same issue I personally experienced with Matplotlib 3.6.3 and Python 3.11 by adding a compatibility branch in _enable_matplotlib_integration for Matplotlib versions >= 3.5.0 and < 3.10.0, using matplotlib.get_backend() without arguments.

Background

In Matplotlib 3.5.0, the private _get() function was removed and replaced by get_backend() for retrieving the current backend. get_backend() accepted no arguments through Matplotlib 3.9.x.

However, _enable_matplotlib_integration currently attempts to use matplotlib.rcParams._get("backend") for Matplotlib versions before 3.10.0. This causes the integration to fail with Matplotlib >= 3.5.0 < 3.10 because _get() is no longer available.

Changes

This change uses:

  • matplotlib.get_backend(auto_select=False) for Matplotlib >= 3.10.0
  • matplotlib.get_backend() for Matplotlib >= 3.5.0 and < 3.10.0
  • matplotlib.rcParams._get("backend") for older Matplotlib versions

Testing

Confirmed that Matplotlib 3.5.0 and 3.6.3 do not include _get().

Tested with Matplotlib 3.6.3 and confirmed that _enable_matplotlib_integration successfully retrieves the backend without raising an AttributeError.

Included a CI test that verifies Matplotlib 3.5.0 and 3.9.9 work with the matplotlib.rcParams.get_backend() function.

Tested that the modified function works correctly with Python 3.10 and Python 3.11.

Copilot AI lite review requested due to automatic review settings September 21, 2026 20:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Fixes Matplotlib backend retrieval compatibility across versions 3.5–3.9 while preserving support for older and newer releases.

Changes:

  • Uses get_backend() for Matplotlib 3.5–3.9.
  • Uses get_backend(auto_select=False) for Matplotlib ≥3.10.
  • Retains the legacy fallback for older versions.
File Description
matplotlib_inline/​backend_inline.py Adds version-aware backend retrieval logic.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incompatibility to matplotlib<3.5.2

2 participants