Skip to content

Commit acf9b40

Browse files
tacaswellmelissawm
authored andcommitted
DOC: clarify when existing figures when switching backend
1 parent 44c34b2 commit acf9b40

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
@@ -1124,6 +1124,10 @@ def use(backend, *, force=True):
11241124
"""
11251125
Select the backend used for rendering and GUI integration.
11261126
1127+
If pyplot is already imported, `~matplotlib.pyplot.switch_backend` is used
1128+
and if the new backend is different than the current backend, all Figures
1129+
will be closed.
1130+
11271131
Parameters
11281132
----------
11291133
backend : str
@@ -1154,6 +1158,8 @@ def use(backend, *, force=True):
11541158
--------
11551159
:ref:`backends`
11561160
matplotlib.get_backend
1161+
matplotlib.pyplot.switch_backend
1162+
11571163
"""
11581164
name = validate_backend(backend)
11591165
# 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
@@ -210,16 +210,20 @@ def _get_backend_mod():
210210

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

0 commit comments

Comments
 (0)