Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4644c9f

Browse files
authored
Merge pull request #12666 from meeseeksmachine/auto-backport-of-pr-12608-on-v3.0.x
Backport PR #12608 on branch v3.0.x (ENH: allow matplotlib.use after getbackend)
2 parents b47faf4 + 44b8bf7 commit 4644c9f

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

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
@@ -1327,7 +1327,7 @@ def __exit__(self, exc_type, exc_value, exc_tb):
13271327
self.__fallback()
13281328

13291329

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

0 commit comments

Comments
 (0)