Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[MNT]: Move Matplotlib backend mapping from IPython and support backends self-registering #27663

Closed
@ianthomas23

Description

@ianthomas23

Summary

I propose to move the Matplotlib backend mapping that is currently in IPython into Matplotlib, and extend it to support backends registering themselves viaentry_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

  • This is unnecessarily difficult to maintain as new backends require changes in IPython.
  • There is no support in IPython for backends specified using"module://whatever.backend.module"

Proposal

  1. 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.
  2. Add a backend registry to Matplotlib. Whether this is literally aBackendRegistry singleton or not is an implementation detail.
  3. The registry will allow use of backends for both IPython andmatplotlib.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 anentry_point. Initially this will beipympl andmatplotlib-inline.
  4. Need to handle error situations of multiple backends registering under the same name, or registering with the same name as a built-in backend.
  5. Matplotlib needs a newlist_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.
  6. Thelist_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:

  1. Matplotlib = new registry, looking up entry points, docs.
  2. Matplotlib-inline = add entry point.
  3. Ipympl = add entry point.
  4. IPython = call Matplotlib backend registry for backend info, docs.

Changes 1-3 will need to be published in releases before 4 can be merged and released.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp