Skip to content

Clarify docstring of [un]install_repl_displayhook() #22911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ def _draw_all_if_interactive():

def install_repl_displayhook():
"""
Install a repl display hook so that any stale figure are automatically
redrawn when control is returned to the repl.
Connect to the display hook of the current shell.

The display hook gets called when the read-evaluate-print-loop (REPL) of
the shell has finished the execution of a command. We use this callback
to be able to automatically update a figure in interactive mode.

This works both with IPython and with vanilla python shells.
"""
Expand Down Expand Up @@ -155,15 +158,7 @@ def install_repl_displayhook():


def uninstall_repl_displayhook():
"""
Uninstall the Matplotlib display hook.

.. warning::

If you are using vanilla python and have installed another display hook,
this will reset `sys.displayhook` to what ever function was there when
Matplotlib installed its displayhook, possibly discarding your changes.
"""
"""Disconnect from the display hook of the current shell."""
global _REPL_DISPLAYHOOK
if _REPL_DISPLAYHOOK is _ReplDisplayHook.IPYTHON:
from IPython import get_ipython
Expand Down