Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bersbersbers opened this issue Mar 29, 2021 · 2 comments · Fixed by #19822
Closed

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

bersbersbers opened this issue Mar 29, 2021 · 2 comments · Fixed by #19822

Comments

@bersbersbers
Copy link
Contributor

bersbersbers commented Mar 29, 2021

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)
@bersbersbers
Copy link
Contributor Author

Not sure if it makes sense to discuss this here, but I don't like to open a new issue for this: Is there a way to select any available, non-interactive backend? Currently, this would mean trying AGG first, then falling back to Cairo if that fails. Can this be done in a future-proof way?

@bersbersbers
Copy link
Contributor Author

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants