Skip to content

Add a public backend fallback API #17386

Open

Description

@anntzer

Bug report

Bug summary

Back in #11600/#11896 I added backend fallback autodetection, which (by default) picks the first available backend among macosx, qt5agg, qt4agg, gtk3agg, etc. Initially the fallback order was configurable, but that got removed before the PRs were merged because of concerns about the API. I would like to revive that feature (essentially so that I can configure my envs to use module://mplcairo.qt by default, but module://mplcairo.base when no $DISPLAY is available). In itself it's not really hard, it's just a matter of what API we expose. One concern was that the initial approach was to put the list of backends to attempt in rcParams["backend"], which made that entry "active" (it's not just a plain dict entry, but something rather more complicated). One possible API (considering that this mostly just only needs to work before importing matplotlib) may be to only support configuring this in the $MPLBACKEND environment variable, which could e.g. be set to a (semi?)colon-separated list of backends to attempt.

Activity

  1. QuLogic commented on May 12, 2020

    @QuLogic
    Member

    Since colon goes in module://, I guess that won't work as separator. A comma or semi-colon would work, as they aren't allowed in import paths.

  2. added this to the v3.4.0 milestone on May 12, 2020
  3. anntzer commented on May 14, 2020

    @anntzer
    ContributorAuthor

    Let's just use a comma, that'll save on having to quote it (and I don't see many reasons to not pick it).

  4. modified the milestones: v3.4.0, v3.5.0 on Jan 27, 2021
  5. modified the milestones: v3.5.0, v3.6.0 on Sep 25, 2021
  6. modified the milestones: v3.6.0, v3.7.0 on Aug 24, 2022
  7. github-actions commented on Apr 6, 2026

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  8. added
    keepItems to be ignored by the “Stale” Github Action
    on Apr 6, 2026
  9. anntzer commented on Apr 6, 2026

    @anntzer
    ContributorAuthor

    Still a useful addition, IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Actionstatus: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions