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

Commit307c1ec

Browse files
committed
Also update the backend when doing rcParams["backend"] = "foo".
1 parent2047ace commit307c1ec

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

‎lib/matplotlib/rcsetup.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,28 @@ def validate_backend(s):
262262
lambdas:
263263
sifs.startswith("module://")
264264
elseValidateInStrings('backend',all_backends,ignorecase=True)(s))(s)
265+
pyplot=sys.modules.get("matplotlib.pyplot")
265266
iflen(candidates)==1:
266-
returncandidates[0]
267+
backend,=candidates
268+
ifpyplot:
269+
# This import needs to be delayed (below too) because it is not
270+
# available at first import.
271+
frommatplotlibimportrcParams
272+
# Don't recurse.
273+
old_backend=rcParams["backend"]
274+
ifold_backend==backend:
275+
returnbackend
276+
dict.__setitem__(rcParams,"backend",backend)
277+
try:
278+
pyplot.switch_backend(backend)
279+
exceptException:
280+
dict.__setitem__(rcParams,"backend",old_backend)
281+
raise
282+
returnbackend
267283
else:
268-
pyplot=sys.modules.get("matplotlib.pyplot")
269284
ifpyplot:
270-
pyplot.switch_backend(candidates)# Actually resolves the backend.
271285
frommatplotlibimportrcParams
286+
pyplot.switch_backend(candidates)# Actually resolves the backend.
272287
returnrcParams["backend"]
273288
else:
274289
returncandidates

‎lib/matplotlib/tests/test_backend_qt4.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
exceptImportError:
1414
importmock
1515

16-
withmatplotlib.rc_context(rc={'backend':'Qt4Agg'}):
17-
qt_compat=pytest.importorskip('matplotlib.backends.qt_compat')
18-
frommatplotlib.backends.backend_qt4import (
19-
MODIFIER_KEYS,SUPER,ALT,CTRL,SHIFT)# noqa
16+
pytest.importorskip('PyQt4')
17+
qt_compat=pytest.importorskip('matplotlib.backends.qt_compat')
2018

2119
QtCore=qt_compat.QtCore
2220
_,ControlModifier,ControlKey=MODIFIER_KEYS[CTRL]

‎lib/matplotlib/tests/test_backend_qt5.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
exceptImportError:
1717
importmock
1818

19-
withmatplotlib.rc_context(rc={'backend':'Qt5Agg'}):
20-
qt_compat=pytest.importorskip('matplotlib.backends.qt_compat',
21-
minversion='5')
19+
pytest.importorskip('PyQt5')
20+
qt_compat=pytest.importorskip('matplotlib.backends.qt_compat',
21+
minversion='5')
22+
2223
frommatplotlib.backends.backend_qt5import (
2324
MODIFIER_KEYS,SUPER,ALT,CTRL,SHIFT)# noqa
2425

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp