8000 Document standard backends in matplotlib.use() · matplotlib/matplotlib@b320d1f · GitHub
[go: up one dir, main page]

Skip to content

Commit b320d1f

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

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

lib/matplotlib/__init__.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,16 +1311,23 @@ def use(arg, warn=True, force=False):
13111311
"""
13121312
Set the matplotlib backend to one of the known backends.
13131313
1314-
To find out which backend is currently set, see
1315-
:func:`matplotlib.get_backend`.
1316-
1317-
13181314
Parameters
13191315
----------
13201316
arg : str
13211317
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.
1318+
'standard' backend names:
1319+
1320+
- interactive backends:
1321+
GTK3Agg, GTK3Cairo, MacOSX, nbAgg,
1322+
Qt4Agg, Qt4Cairo, Qt5Agg, Qt5Cairo,
1323+
TkAgg, TkCairo, WebAgg, WX, WXAgg, WXCairo
1324+
1325+
- non-interactive backends:
1326+
agg, cairo, pdf, pgf, ps, svg, template
1327+
1328+
or a string of the form: ``module://my.module.name``.
1329+
1330+
This value is case-insensitive.
13241331
13251332
warn : bool, optional
13261333
If True, warn if this is called after pyplot has been imported
@@ -1332,7 +1339,10 @@ def use(arg, warn=True, force=False):
13321339
If True, attempt to switch the backend. This defaults to
13331340
False.
13341341
1335-
1342+
See Also
1343+
--------
1344+
:ref:`backends`
1345+
matplotlib.get_backend
13361346
"""
13371347
name = validate_backend(arg)
13381348

@@ -1371,7 +1381,13 @@ def use(arg, warn=True, force=False):
13711381

13721382

13731383
def get_backend():
1374-
"""Return the name of the current backend."""
1384+
"""
1385+
Return the name of the current backend.
1386+
1387+
See Also
1388+
--------
1389+
matplotlib.use
1390+
"""
13751391
return rcParams['backend']
13761392

13771393

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)
0