8000 Backport PR #12608: ENH: allow matplotlib.use after getbackend · matplotlib/matplotlib@44b8bf7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 44b8bf7

Browse files
tacaswellMeeseeksDev[bot]
authored andcommitted
Backport PR #12608: ENH: allow matplotlib.use after getbackend
1 parent 0593c59 commit 44b8bf7

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Matplotlib.use now has an ImportError for interactive backend
2+
-------------------------------------------------------------
3+
4+
Switching backends via `matplotlib.use` is now allowed by default,
5+
regardless of whether `matplotlib.pyplot` has been imported. If the user
6+
tries to switch from an already-started interactive backend to a different
7+
interactive backend, an ImportError will be raised.

lib/matplotlib/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ def __exit__(self, exc_type, exc_value, exc_tb):
13261326
self.__fallback()
13271327

13281328

1329-
def use(arg, warn=True, force=False):
1329+
def use(arg, warn=False, force=True):
13301330
"""
13311331
Set the matplotlib backend to one of the known backends.
13321332
@@ -1352,11 +1352,12 @@ def use(arg, warn=True, force=False):
13521352
If True, warn if this is called after pyplot has been imported
13531353
and a backend is set up.
13541354
1355-
defaults to True
1355+
defaults to False.
13561356
13571357
force : bool, optional
1358-
If True, attempt to switch the backend. This defaults to
1359-
False.
1358+
If True, attempt to switch the backend. An ImportError is raised if
1359+
an interactive backend is selected, but another interactive
1360+
backend has already started. This defaults to True.
13601361
13611362
See Also
13621363
--------

0 commit comments

Comments
 (0)
0