Skip to content

Docs: default backend is not always "agg" (e.g., if X11 is working) #19813

Closed
@bersbersbers

Description

@bersbersbers

Problem

One may get the impression that "agg" is the default backend from reading

There are three ways to configure your backend:

  1. The rcParams["backend"] (default: 'agg') parameter in your matplotlibrc file
  2. The MPLBACKEND environment variable
  3. The function matplotlib.use()

https://matplotlib.org/stable/tutorials/introductory/usage.html#selecting-a-backend

So, not having a matplotlibrc nor MPLBACKEND, I would expect that "agg" is default. However, with DISPLAY set and an X11 server running, I get

user@host:~/cia> xeyes; echo $?; python -c "import matplotlib as mpl; print(mpl.get_backend())"
0
TkAgg

Only after closing the X11 server, everything is as expected:

user@host:~/cia> xeyes; echo $?; python -c "import matplotlib as mpl; print(mpl.get_backend())"
Error: Can't open display: localhost:12.0
1
agg

Suggested Improvement

  • Explain that an interactive backend is selected by default if available.
  • Make sure people find this information when searching for "TkAgg" (in case someone looks for this when trying to understand why they get what I observe).
  • Remove "(default: 'agg')" from rcParams["backend"] (because it's not always correct)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions