Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 096d714

Browse filesBrowse files
committed
ENH : added uninstall for repl displayhook
1 parent f41ae9e commit 096d714
Copy full SHA for 096d714

File tree

Expand file treeCollapse file tree

1 file changed

+34
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+34
-0
lines changed

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,40 @@ def displayhook(*args):
159159

160160
sys.displayhook = displayhook
161161

162+
163+
def uninstall_repl_displayhook():
164+
"""
165+
Uninstalls the matplotlib display hook.
166+
167+
.. warning
168+
169+
Need IPython >= 2 for this to work. For IPython < 2 will raise a
170+
``NotImplementedError``
171+
172+
.. warning
173+
174+
If you are using vanilla python and have installed another
175+
display hook this will reset ``sys.displayhook`` to what ever
176+
function was there when matplotlib installed it's displayhook,
177+
possibly discarding your changes.
178+
"""
179+
global _BASE_DH
180+
global _IP_REGISTERED
181+
if _IP_REGISTERED:
182+
from IPython import get_ipython
183+
ip = get_ipython()
184+
try:
185+
ip.events.unregister('post_execute', draw_all)
186+
except AttributeError:
187+
raise NotImplementedError("Can not unregister events "
188+
"in IPython < 2.0")
189+
_IP_REGISTERED = False
190+
191+
if _BASE_DH:
192+
sys.displayhook = _BASE_DH
193+
_BASE_DH = None
194+
195+
162196
draw_all = _pylab_helpers.Gcf.draw_all
163197

164198

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.