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

Appearance settings

[ENH]: Does pyplot need to call switch_backend #22739

Copy link
Copy link
Closed
@hmaarrfk

Description

@hmaarrfk
Issue body actions

Problem

It seems that simply importing pyplot can have serious effects on what backends are chosen, and how they interact with one and other.

In

# if pyplot is not already imported, do not import it. Doing

They say that simply

from matplotlib import pyplot

can trigger setting the default backend.

This is somewhat frustrating for people who use interactive sessions.

Running the code

from matplotlib import pyplot
import matplotlib
matplotlib.use("WxAgg")

all at once will work in ipython (from the terminal). But running it one line at a time, won't.

This is somewhat strange.

Now that things like __getattr__ exist, would be possible to further delay setting the default backend?

The issue arises when you want to build an application, and other people's code might be imported before yours. You are then at their mercy to not set the backend (implicitly!) before you set yours.

Proposed solution

No solution. I'm sure there is some strange historic thing I'm missing.

Honestly, you created a great API with pyplot. People use it to get colormaps, and for all sorts of things.

XREF: DeepLabCut/DeepLabCut#1730

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.