Avoid using Agg backend if running on Binder
@@ -56,6 +56,7 @@ Misc Functions
'''
import os
import sys
+import getpass
import matplotlib as mpl
# if running on remote mode on a linux server which does not have a display (like Docker images for CI)
@@ -63,6 +64,7 @@ import matplotlib as mpl
if os.name == 'posix' and not os.environ.get('DISPLAY', '') and mpl.rcParams['backend'] != 'agg' and sys.version.startswith('2'):
print('No display found. Using non-interactive Agg backend.')
# https://matplotlib.org/faq/usage_faq.html
+ if getpass.getuser() != 'jovyan': # only if not running on Binder
mpl.use('Agg')
from matplotlib import ticker
import matplotlib.pyplot as plb
