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

revamp setting matplotlib backend #242

Closed
paxtonfitzpatrick opened this issue Oct 7, 2020 · 0 comments · Fixed by #245
Closed

revamp setting matplotlib backend #242

paxtonfitzpatrick opened this issue Oct 7, 2020 · 0 comments · Fixed by #245
Assignees

Comments

@paxtonfitzpatrick
Copy link
Member

the plot submodule currently tries to set the backend to TkAgg when hypertools Is first imported, and shows a warning if it fails.

#!/usr/bin/env python
import warnings
import matplotlib as mpl
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
mpl.use('TkAgg')
except:
warnings.warn('Could not switch backend to TkAgg. This may impact performance of the plotting functions.')

This creates a whole bunch of issues:

  1. silently changes the backend that may have been previously set by the user
  2. If tkinter isn't installed or set up, matplotlib falls back to the non-GUI Agg backend. This means plots won't display at all, even if there is a different non-tkinter backend available
  3. In environments without X11 installed (e.g., small Docker containers), the warning is either shown or has to be suppressed manually any time hypertools is imported, even if not for plotting.
  4. if imported into a notebook, it creates a phantom Python process that can't be killed without the IPython kernel dying
  5. if hypertools is imported after matplotlib.pyplot, no plots will show at all because of a post-execute callback that matplotlib sets when imported into a notebook where the backend hasn't been manually set yet.

I'm working on a fix to this and will open a PR once finished

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