Title: [MNT]: Move Matplotlib backend mapping from IPython and support backends self-registering · Issue #27663 · matplotlib/matplotlib · GitHub
Open Graph Title: [MNT]: Move Matplotlib backend mapping from IPython and support backends self-registering · Issue #27663 · matplotlib/matplotlib
X Title: [MNT]: Move Matplotlib backend mapping from IPython and support backends self-registering · Issue #27663 · matplotlib/matplotlib
Description: 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 ...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/27663
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[MNT]: Move Matplotlib backend mapping from IPython and support backends self-registering","articleBody":"### Summary\n\nI 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 https://github.com/matplotlib/matplotlib/pull/19482#issuecomment-1042511334.\n\n### Proposed fix\n\n# Background\r\n\r\nIPython supports the use of the `%matplotlib` magic in two ways:\r\n- `%matplotlib \u003cbackend_name\u003e` to use the named Matplotlib backend.\r\n- `%matplotlib --list` to list available backends.\r\n\r\nIPython 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.\r\n\r\n# Problems\r\n\r\n- This is unnecessarily difficult to maintain as new backends require changes in IPython.\r\n- There is no support in IPython for backends specified using `\"module://whatever.backend.module\"`\r\n\r\n# Proposal\r\n\r\n1. Keep the same `%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.\r\n2. Add a backend registry to Matplotlib. Whether this is literally a `BackendRegistry` singleton or not is an implementation detail.\r\n3. The registry will allow use of backends for both IPython and `matplotlib.use` in three different categories:\r\n a. Backends that are built into the Matplotlib code base.\r\n b. Backends that can be dynamically loaded using `\"module://backend.name\"` such as MplCairo.\r\n c. Backends that register themselves using an `entry_point`. Initially this will be `ipympl` and `matplotlib-inline`.\r\n4. Need to handle error situations of multiple backends registering under the same name, or registering with the same name as a built-in backend.\r\n5. Matplotlib needs a new `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.\r\n6. The `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.\r\n\r\nThis isn’t the full set of functionality listed at https://github.com/matplotlib/matplotlib/pull/19482#issuecomment-1042511334 as it does not include use of `\"m://…\"` form for example.\r\n\r\nChanges will be required in the following projects:\r\n1. Matplotlib = new registry, looking up entry points, docs.\r\n2. Matplotlib-inline = add entry point.\r\n3. Ipympl = add entry point.\r\n4. IPython = call Matplotlib backend registry for backend info, docs.\r\n\r\nChanges 1-3 will need to be published in releases before 4 can be merged and released.\r\n","author":{"url":"https://github.com/ianthomas23","@type":"Person","name":"ianthomas23"},"datePublished":"2024-01-17T16:29:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/27663/matplotlib/issues/27663"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:40b282d7-51bb-d1c6-d3e0-33188d1bfac8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8FA:3EE843:5E169:7F51F:6A535E53 |
| html-safe-nonce | 19e52de8f84d3ed024eeb2bec038077ee71730b275145648589d75f1ce372f9d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEZBOjNFRTg0Mzo1RTE2OTo3RjUxRjo2QTUzNUU1MyIsInZpc2l0b3JfaWQiOiI1MTMwNzEyNDAzOTUzMjc4NTQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e9de3a27babe43519aafca425521b0dac6583943357be879a74a49eae0d2adbe |
| hovercard-subject-tag | issue:2086546557 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/27663/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c315b27a8da68ae8310583a9b3bebd9f585e00e2a40e52a75957d4caed19e825/matplotlib/matplotlib/issues/27663 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c315b27a8da68ae8310583a9b3bebd9f585e00e2a40e52a75957d4caed19e825/matplotlib/matplotlib/issues/27663 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ianthomas23 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width