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].
[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)
EB sets
MPLBACKEND
toAgg
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, https://github.com/matplotlib/matplotlib/pull/17396 pulled in a improved matplotlib backend fallback since v3.3.3.
Is this something that could be changed?
[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.