You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to draw your attention to matplotlib/matplotlib#27663, about moving the Matplotlib backend mappings out of IPython and into Matplotlib.
The primary use case it so support Matplotlib widgets (ipympl and matplotlib-inline) registering themselves as Matplotlib backends without requiring additional code in IPython and/or Matplotlib. The secondary use case is to support backends in IPython using Matplotlib's module://name.of.the.backend syntax, e.g.
%matplotlib module://mplcairo.backend
which one can already do using matplotlib.use(...) but not directly via the %matplotlib magic.
Whilst doing this it seems sensible to bring all of the backend registering and mapping together in one place, and that should be Matplotlib rather than IPython. I am not sure how easy (or even possible!) it will be to remove all the related hard-coded stuff in IPython, but I am willing to start and see how it goes.
Thanks for opening this up for awareness, @ianthomas23 ! This sounds like a good plan to me. I think the only modification we'd want is to keep the current hardcoded functionality to support older versions of Matplotlib that will not have the list_backends, as there are users who update some packages while pinning others, so we would not want to break them by assuming that when they get a newer IPython they will also get a recent Matplotlib.
Thanks both. Yes, I'll put in a check on matplotlib.__version__ and use the existing code for "old" Matplotlib.
I have a concern about backend2gui. It won't be needed in future (apart from the above fallback) but I wonder if other downstream libraries might be using it such that it cannot just be removed. Maybe I need to add a shim so that use of backend2gui does the right thing by calling Matplotlib as necessary.
Activity
ivanov commentedon Jan 30, 2024
Thanks for opening this up for awareness, @ianthomas23 ! This sounds like a good plan to me. I think the only modification we'd want is to keep the current hardcoded functionality to support older versions of Matplotlib that will not have the
list_backends, as there are users who update some packages while pinning others, so we would not want to break them by assuming that when they get a newer IPython they will also get a recent Matplotlib.Carreau commentedon Jan 31, 2024
+1, I have no issue hardcoding a matplotlib version check in IPython to either fall to the hardcoded path or assuming things get registered.
ianthomas23 commentedon Jan 31, 2024
Thanks both. Yes, I'll put in a check on
matplotlib.__version__and use the existing code for "old" Matplotlib.I have a concern about
backend2gui. It won't be needed in future (apart from the above fallback) but I wonder if other downstream libraries might be using it such that it cannot just be removed. Maybe I need to add a shim so that use ofbackend2guidoes the right thing by calling Matplotlib as necessary.Carreau commentedon Jan 31, 2024
We can add a getattr to the module level that warns about pending deprecation on access.
Move Matplotlib backend mapping to Matplotlib (#14371)