Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22c55e9

Browse files
committed
Cleanup matplotlib.use
1 parent0c35833 commit22c55e9

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
API Changes
2+
```````````
3+
4+
The first parameter of `matplotlib.use` has been renamed from *arg* to
5+
*backend*. This will only affect cases where that parameter has been set
6+
as a keyword argument. The common usage pattern as a positional argument
7+
(``matplotlib.use('Qt5Agg')`` is not affected.

‎lib/matplotlib/__init__.py

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,15 +1297,15 @@ def __exit__(self, exc_type, exc_value, exc_tb):
12971297
self.__fallback()
12981298

12991299

1300-
defuse(arg,warn=False,force=True):
1300+
defuse(backend,warn=False,force=True):
13011301
"""
1302-
Set the matplotlib backendto one of the known backends.
1302+
Select the matplotlib backendfor rendering.
13031303
13041304
Parameters
13051305
----------
1306-
arg : str
1307-
The backend to switch to. This can either be one of the
1308-
'standard'backend names:
1306+
backend : str
1307+
The backend to switch to. This can either be one of the standard
1308+
backend names:
13091309
13101310
- interactive backends:
13111311
GTK3Agg, GTK3Cairo, MacOSX, nbAgg,
@@ -1319,50 +1319,47 @@ def use(arg, warn=False, force=True):
13191319
13201320
Note: Standard backend names are case-insensitive here.
13211321
1322-
warn : bool, optional
1323-
If True, warnif this is called after pyplot has been imported
1324-
and a backend is set up.
1322+
warn : bool, optional, default: False
1323+
If True and not *force*, warnthat the call will have no effect if
1324+
this is called after pyplot has been importedand a backend is set up.
13251325
1326-
defaults to False.
1327-
1328-
force : bool, optional
1326+
force : bool, optional, default: True
13291327
If True, attempt to switch the backend. An ImportError is raised if
13301328
an interactive backend is selected, but another interactive
1331-
backend has already started. This defaults to True.
1329+
backend has already started.
13321330
13331331
See Also
13341332
--------
13351333
:ref:`backends`
13361334
matplotlib.get_backend
13371335
"""
1338-
name=validate_backend(arg)
1336+
name=validate_backend(backend)
13391337

1340-
#ifsetting back to the same thing, do nothing
1341-
if(dict.__getitem__(rcParams,'backend')==name):
1338+
ifdict.__getitem__(rcParams,'backend')==name:
1339+
# Nothing to doifthe requestedbackend is already set
13421340
pass
1343-
1344-
# Check if we have already imported pyplot and triggered
1345-
# backend selection, do a bit more work
13461341
elif'matplotlib.pyplot'insys.modules:
1347-
# If we are here then the requested is different than the current.
1342+
# pyplot has already been imported (which triggered backend selection)
1343+
# and the requested backend is different from the current one.
1344+
13481345
# If we are going to force the switch, never warn, else, if warn
13491346
# is True, then direct users to `plt.switch_backend`
13501347
if (notforce)andwarn:
13511348
cbook._warn_external(
1352-
("matplotlib.pyplotas already been imported, "
1353-
"this call will have no effect."))
1349+
"matplotlib.pyplothas already been imported, "
1350+
"this call will have no effect.")
13541351

13551352
# if we are going to force switching the backend, pull in
13561353
# `switch_backend` from pyplot. This will only happen if
13571354
# pyplot is already imported.
13581355
ifforce:
13591356
frommatplotlib.pyplotimportswitch_backend
13601357
switch_backend(name)
1361-
# Finally if pyplot is not imported update both rcParams and
1362-
# rcDefaults so restoring the defaults later with rcdefaults
1363-
# won't change the backend. This is a bit of overkill as 'backend'
1364-
# is already in style.core.STYLE_BLACKLIST, but better to be safe.
13651358
else:
1359+
# Finally if pyplot is not imported update both rcParams and
1360+
# rcDefaults so restoring the defaults later with rcdefaults
1361+
# won't change the backend. This is a bit of overkill as 'backend'
1362+
# is already in style.core.STYLE_BLACKLIST, but better to be safe.
13661363
rcParams['backend']=rcParamsDefault['backend']=name
13671364

13681365

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp