@@ -1338,6 +1338,7 @@ def rc_file_defaults():
13381338 """
13391339 rcParams .update (rcParamsOrig )
13401340
1341+
13411342_use_error_msg = """
13421343This call to matplotlib.use() has no effect because the backend has already
13431344been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
@@ -1408,6 +1409,12 @@ def use(arg, warn=True, force=False):
14081409 reload (sys .modules ['matplotlib.backends' ])
14091410
14101411
1412+ try :
1413+ use (os .environ ['MPLBACKEND' ])
1414+ except KeyError :
1415+ pass
1416+
1417+
14111418def get_backend ():
14121419 """Return the name of the current backend."""
14131420 return rcParams ['backend' ]
@@ -1435,33 +1442,6 @@ def tk_window_focus():
14351442 return False
14361443 return rcParams ['tk.window_focus' ]
14371444
1438- # Now allow command line to override
1439-
1440- # Allow command line access to the backend with -d (MATLAB compatible
1441- # flag)
1442-
1443- for s in sys .argv [1 :]:
1444- # cast to str because we are using unicode_literals,
1445- # and argv is always str
1446- if s .startswith (str ('-d' )) and len (s ) > 2 : # look for a -d flag
1447- try :
1448- use (s [2 :])
1449- warnings .warn ("Using the -d command line argument to select a "
1450- "matplotlib backend is deprecated. Please use the "
1451- "MPLBACKEND environment variable instead." ,
1452- mplDeprecation )
1453- break
1454- except (KeyError , ValueError ):
1455- pass
1456- # we don't want to assume all -d flags are backends, e.g., -debug
1457- else :
1458- # no backend selected from the command line, so we check the environment
1459- # variable MPLBACKEND
1460- try :
1461- use (os .environ ['MPLBACKEND' ])
1462- except KeyError :
1463- pass
1464-
14651445
14661446# Jupyter extension paths
14671447def _jupyter_nbextension_paths ():
0 commit comments