File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,40 @@ def displayhook(*args):
159
159
160
160
sys .displayhook = displayhook
161
161
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
+
162
196
draw_all = _pylab_helpers .Gcf .draw_all
163
197
164
198
You can’t perform that action at this time.
0 commit comments