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

Skip to content

Commit 8c44c4d

Browse files
authored
Merge pull request #12608 from jklymak/enh-change-backend
API: allow matplotlib.use after getbackend
2 parents c921e2e + c87e2da commit 8c44c4d

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
@@ -1296,7 +1296,7 @@ def __exit__(self, exc_type, exc_value, exc_tb):
12961296
self.__fallback()
12971297

12981298

1299-
def use(arg, warn=True, force=False):
1299+
def use(arg, warn=False, force=True):
13001300
"""
13011301
Set the matplotlib backend to one of the known backends.
13021302
@@ -1322,11 +1322,12 @@ def use(arg, warn=True, force=False):
13221322
If True, warn if this is called after pyplot has been imported
13231323
and a backend is set up.
13241324
1325-
defaults to True
1325+
defaults to False.
13261326
13271327
force : bool, optional
1328-
If True, attempt to switch the backend. This defaults to
1329-
False.
1328+
If True, attempt to switch the backend. An ImportError is raised if
1329+
an interactive backend is selected, but another interactive
1330+
backend has already started. This defaults to True.
13301331
13311332
See Also
13321333
--------

0 commit comments

Comments
 (0)