Skip to content
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

Matplotlib Agg backend #772

Open
hattom opened this issue Jan 10, 2022 · 0 comments
Open

Matplotlib Agg backend #772

hattom opened this issue Jan 10, 2022 · 0 comments

Comments

@hattom
Copy link
Contributor

hattom commented Jan 10, 2022

EB sets MPLBACKEND to Agg by default to give a non-interactive backend.
Whilst this solves the problem of "why won't my matplotlib work in the batch system" [1], it leads to the trickier problem of "how to get matplotlib to be interactive when I want to use it interactively?" [2].

According to the Slack discussion, matplotlib/matplotlib#17396 pulled in a improved matplotlib backend fallback since v3.3.3.

Is this something that could be changed?

  • Thomas

[1] one for which people are often accustomed and have good workarounds
[2] My personal approach to support EB's matplotlib now looks something like this. I'm sure there's a better way, but I don't know what it is.

from os import environ
import matplotlib
if 'DISPLAY' not in environ:
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt 
else:
    import matplotlib.pyplot as plt 
    if not matplotlib.is_interactive():
        plt.switch_backend(matplotlib.rcsetup._auto_backend_sentinel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant