Skip to content

Commit 0d995d4

Browse files
committed
allow selecting the backend by setting the environment variable MPL_BACKEND
1 parent a220e1f commit 0d995d4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/matplotlib/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,9 +1373,18 @@ def tk_window_focus():
13731373
if s.startswith(str('-d')) and len(s) > 2: # look for a -d flag
13741374
try:
13751375
use(s[2:])
1376+
break
13761377
except (KeyError, ValueError):
13771378
pass
13781379
# we don't want to assume all -d flags are backends, e.g., -debug
1380+
else:
1381+
# no backend selected from the command line, so we check the environment
1382+
# variable MPL_BACKEND
1383+
if 'MPL_BACKEND' in os.environ:
1384+
try:
1385+
use(os.environ['MPL_BACKEND'])
1386+
except (KeyError, ValueError):
1387+
pass
13791388

13801389
default_test_modules = [
13811390
'matplotlib.tests.test_agg',

0 commit comments

Comments
 (0)