-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[MNT]: Move Matplotlib backend mapping from IPython and support backends self-registering #27663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can we put this on the agenda for the meeting tomorrow? |
Yes, I can attend the meeting. |
attn @anntzer |
I'll try to attend tomorrow as well. |
Following discussion at the weekly meeting (https://hackmd.io/l9vkn_T4RSmk147H_ZPPBA#ipython--Matplotlib-integration) I am going ahead with an implementation of this and we will see what problems come up. |
This was referenced Jan 30, 2024
This was referenced Mar 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
I propose to move the Matplotlib backend mapping that is currently in IPython into Matplotlib, and extend it to support backends registering themselves via
entry_points
. This was originally discussed in #19482 and Tom summarised and proposed a solution in #19482 (comment).Proposed fix
Background
IPython supports the use of the
%matplotlib
magic in two ways:%matplotlib <backend_name>
to use the named Matplotlib backend.%matplotlib --list
to list available backends.IPython contains hard-coded information about which backends exist, and which GUI interactive framework they support. The current information consists of backends that are built-into mpl itself (e.g. qt, notebook, webagg) and those in external libraries (ipympl and inline) which are Jupyter-based.
Problems
"module://whatever.backend.module"
Proposal
%matplotlib
magic functionality in IPython but defer responsibility for the backend naming and interactive framework identification to Matplotlib, with a version check of Matplotlib to fallback to the existing behaviour if necessary.BackendRegistry
singleton or not is an implementation detail.matplotlib.use
in three different categories:a. Backends that are built into the Matplotlib code base.
b. Backends that can be dynamically loaded using
"module://backend.name"
such as MplCairo.c. Backends that register themselves using an
entry_point
. Initially this will beipympl
andmatplotlib-inline
.list_backends
function for IPython’s%matplotlib --list
. This will include all backends in items 3a and 3c above, as well as any“module://…”
backends (3b) that have already been loaded. The latter is so that if you use%matplotlib module://…
in IPython a subsequent%matplotlib –list
will include the backend you are using.list_backends
function may as well be public within Matplotlib as it is a feature that is requested every so often. It will have to be clearly stated that this contains “backends that mpl is aware of” rather than an exhaustive list.This isn’t the full set of functionality listed at #19482 (comment) as it does not include use of
"m://…"
form for example.Changes will be required in the following projects:
Changes 1-3 will need to be published in releases before 4 can be merged and released.
The text was updated successfully, but these errors were encountered: