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

Commit511c3ae

Browse files
committed
Cleanup matplotlib.use
1 parent0c35833 commit511c3ae

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
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 & 27 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, which are case-insensitive:
13091309
13101310
- interactive backends:
13111311
GTK3Agg, GTK3Cairo, MacOSX, nbAgg,
@@ -1317,52 +1317,47 @@ def use(arg, warn=False, force=True):
13171317
13181318
or a string of the form: ``module://my.module.name``.
13191319
1320-
Note: Standard backend names are case-insensitive here.
1320+
warn : bool, optional, default: False
1321+
If True and not *force*, warn that the call will have no effect if
1322+
this is called after pyplot has been imported and a backend is set up.
13211323
1322-
warn : bool, optional
1323-
If True, warn if this is called after pyplot has been imported
1324-
and a backend is set up.
1325-
1326-
defaults to False.
1327-
1328-
force : bool, optional
1324+
force : bool, optional, default: True
13291325
If True, attempt to switch the backend. An ImportError is raised if
13301326
an interactive backend is selected, but another interactive
1331-
backend has already started. This defaults to True.
1327+
backend has already started.
13321328
13331329
See Also
13341330
--------
13351331
:ref:`backends`
13361332
matplotlib.get_backend
13371333
"""
1338-
name=validate_backend(arg)
1334+
name=validate_backend(backend)
13391335

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

13551350
# if we are going to force switching the backend, pull in
13561351
# `switch_backend` from pyplot. This will only happen if
13571352
# pyplot is already imported.
13581353
ifforce:
13591354
frommatplotlib.pyplotimportswitch_backend
13601355
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.
13651356
else:
1357+
# Finally if pyplot is not imported update both rcParams and
1358+
# rcDefaults so restoring the defaults later with rcdefaults
1359+
# won't change the backend. This is a bit of overkill as 'backend'
1360+
# is already in style.core.STYLE_BLACKLIST, but better to be safe.
13661361
rcParams['backend']=rcParamsDefault['backend']=name
13671362

13681363

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp