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

Skip to content

Commit 32dd6cc

Browse files
committed
DOC: clarify when existing figures when switching backend
1 parent 5ebb5f9 commit 32dd6cc

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/matplotlib/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,10 @@ def use(backend, *, force=True):
11051105
"""
11061106
Select the backend used for rendering and GUI integration.
11071107
1108+
If pyplot is already imported, `~matplotlib.pyplot.switch_backend` is used
1109+
and if the new backend is different than the current backend, all Figures
1110+
will be closed.
1111+
11081112
Parameters
11091113
----------
11101114
backend : str
@@ -1135,6 +1139,8 @@ def use(backend, *, force=True):
11351139
--------
11361140
:ref:`backends`
11371141
matplotlib.get_backend
1142+
matplotlib.pyplot.switch_backend
1143+
11381144
"""
11391145
name = validate_backend(backend)
11401146
# don't (prematurely) resolve the "auto" backend setting

lib/matplotlib/pyplot.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,20 @@ def _get_backend_mod():
209209

210210
def switch_backend(newbackend):
211211
"""
212-
Close all open figures and set the Matplotlib backend.
212+
Set the pyplot backend.
213213
214-
The argument is case-insensitive. Switching to an interactive backend is
215-
possible only if no event loop for another interactive backend has started.
216-
Switching to and from non-interactive backends is always possible.
214+
Switching to an interactive backend is possible only if no event loop for
215+
another interactive backend has started. Switching to and from
216+
non-interactive backends is always possible.
217+
218+
If the new backend is different than the current backend then all open
219+
Figures will be closed via ``plt.close('all')``.
217220
218221
Parameters
219222
----------
220223
newbackend : str
221-
The name of the backend to use.
224+
The case-insensitive name of the backend to use.
225+
222226
"""
223227
global _backend_mod
224228
# make sure the init is pulled up so we can assign to it later

0 commit comments

Comments
 (0)