Skip to content

Commit

Permalink
Merge pull request #489 from mrclary/mpl390-2x
Browse files Browse the repository at this point in the history
PR: Fix detecting Matplotlib backend for its 3.9.0 version
  • Loading branch information
ccordoba12 committed May 22, 2024
2 parents 3b3765c + 9b2f5a8 commit 3ca2930
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions spyder_kernels/console/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def get_matplotlib_backend(self):
"""Get current matplotlib backend."""
try:
import matplotlib
return MPL_BACKENDS_TO_SPYDER[matplotlib.get_backend()]
return MPL_BACKENDS_TO_SPYDER[matplotlib.get_backend().lower()]
except Exception:
return None

Expand Down Expand Up @@ -428,7 +428,7 @@ def get_mpl_interactive_backend(self):
# equivalent to having the inline one.
return 0
elif framework in mapping:
return MPL_BACKENDS_TO_SPYDER[mapping[framework]]
return MPL_BACKENDS_TO_SPYDER[mapping[framework].lower()]
else:
# This covers the case of other backends (e.g. Wx or Gtk)
# which users can set interactively with the %matplotlib
Expand Down
11 changes: 6 additions & 5 deletions spyder_kernels/utils/mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@

# Mapping of matlotlib backends options to Spyder
MPL_BACKENDS_TO_SPYDER = {
inline_backend: 0,
'Qt5Agg': 2,
'QtAgg': 2, # For Matplotlib 3.5+
'TkAgg': 3,
'MacOSX': 4,
'inline': 0, # For Matplotlib >=3.9
inline_backend: 0, # For Matplotlib <3.9
'qt5agg': 2,
'qtagg': 2, # For Matplotlib 3.5+
'tkagg': 3,
'macosx': 4,
}


Expand Down

0 comments on commit 3ca2930

Please sign in to comment.