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

Skip to content

Commit 27969d6

Browse files
committed
FIX: enable install_repl_displayhook when switching backends
closes #23042 In #22005 we change `pyplot` so that at import time we do not force a switch of the backend and install the repl displayhook. However, this meant that in some cases (primarily through `ipython --pylab`) to end up with a session where `install_repl_displayhook` had never been called.
1 parent f25c2d0 commit 27969d6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,6 @@ def _get_backend_mod():
206206
# will (re)import pyplot and then call switch_backend if we need to
207207
# resolve the auto sentinel)
208208
switch_backend(dict.__getitem__(rcParams, "backend"))
209-
# Just to be safe. Interactive mode can be turned on without calling
210-
# `plt.ion()` so register it again here. This is safe because multiple
211-
# calls to `install_repl_displayhook` are no-ops and the registered
212-
# function respects `mpl.is_interactive()` to determine if it should
213-
# trigger a draw.
214-
install_repl_displayhook()
215209
return _backend_mod
216210

217211

@@ -302,6 +296,10 @@ class backend_mod(matplotlib.backend_bases._Backend):
302296
# See https://github.com/matplotlib/matplotlib/issues/6092
303297
matplotlib.backends.backend = newbackend
304298

299+
# make sure the repl display hook is installed in case we become
300+
# interactive
301+
install_repl_displayhook()
302+
305303

306304
def _warn_if_gui_out_of_main_thread():
307305
if (_get_required_interactive_framework(_get_backend_mod())

0 commit comments

Comments
 (0)