Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf9862c

Browse files
committed
Document standard backends in matplotlib.use()
1 parent 5d2d37e commit bf9862c

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

lib/matplotlib/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,8 +1319,19 @@ def use(arg, warn=True, force=False):
13191319
----------
13201320
arg : str
13211321
The backend to switch to. This can either be one of the
1322-
'standard' backend names or a string of the form
1323-
``module://my.module.name``. This value is case-insensitive.
1322+
'standard' backend names:
1323+
1324+
- interactive backends:
1325+
'GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg',
1326+
'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo',
1327+
'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo'
1328+
1329+
- non-interactive backends:
1330+
'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template'
1331+
1332+
or a string of the form: ``module://my.module.name``.
1333+
1334+
This value is case-insensitive.
13241335
13251336
warn : bool, optional
13261337
If True, warn if this is called after pyplot has been imported
@@ -1332,7 +1343,6 @@ def use(arg, warn=True, force=False):
13321343
If True, attempt to switch the backend. This defaults to
13331344
False.
13341345
1335-
13361346
"""
13371347
name = validate_backend(arg)
13381348

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import matplotlib
2+
import matplotlib.rcsetup
3+
4+
5+
def test_use_doc_standard_backends():
6+
"""
7+
Test that the standard backends mentioned in the docstring of
8+
matplotlib.use() are the same as in matplotlib.rcsetup.
9+
"""
10+
def parse(key):
11+
backends = []
12+
for line in matplotlib.use.__doc__.split(key)[1].split('\n'):
13+
if not line or not line.strip().startswith("'"):
14+
break
15+
backends += [e.strip().strip("'") for e in line.split(',') if e]
16+
return backends
17+
18+
assert (set(parse('- interactive backends:\n')) ==
19+
set(matplotlib.rcsetup.interactive_bk))
20+
assert (set(parse('- non-interactive backends:\n')) ==
21+
set(matplotlib.rcsetup.non_interactive_bk))

0 commit comments

Comments
 (0)