@@ -108,84 +108,6 @@ def _backend_selection():
108108from matplotlib .backends import pylab_setup
109109_backend_mod , new_figure_manager , draw_if_interactive , _show = pylab_setup ()
110110
111- _IP_REGISTERED = None
112- _INSTALL_FIG_OBSERVER = False
113-
114- def install_repl_displayhook ():
115- """
116- Install a repl display hook so that any stale figure are automatically
117- redrawn when control is returned to the repl.
118-
119- This works with both IPython terminals and vanilla python shells.
120- """
121- global _IP_REGISTERED
122- global _INSTALL_FIG_OBSERVER
123-
124- class _NotIPython (Exception ):
125- pass
126-
127- # see if we have IPython hooks around, if use them
128-
129- try :
130- from IPython import get_ipython
131- ip = get_ipython ()
132- if ip is None :
133- raise _NotIPython ()
134-
135- if _IP_REGISTERED :
136- return
137-
138- def post_execute ():
139- if matplotlib .is_interactive ():
140- draw_all ()
141-
142- # IPython >= 2
143- try :
144- ip .events .register ('post_execute' , post_execute )
145- except AttributeError :
146- # IPython 1.x
147- ip .register_post_execute (post_execute )
148-
149- _IP_REGISTERED = post_execute
150- _INSTALL_FIG_OBSERVER = False
151-
152- # import failed or ipython is not running
153- except (ImportError , _NotIPython ):
154- _INSTALL_FIG_OBSERVER = True
155-
156-
157- def uninstall_repl_displayhook ():
158- """
159- Uninstalls the matplotlib display hook.
160-
161- .. warning
162-
163- Need IPython >= 2 for this to work. For IPython < 2 will raise a
164- ``NotImplementedError``
165-
166- .. warning
167-
168- If you are using vanilla python and have installed another
169- display hook this will reset ``sys.displayhook`` to what ever
170- function was there when matplotlib installed it's displayhook,
171- possibly discarding your changes.
172- """
173- global _IP_REGISTERED
174- global _INSTALL_FIG_OBSERVER
175- if _IP_REGISTERED :
176- from IPython import get_ipython
177- ip = get_ipython ()
178- try :
179- ip .events .unregister ('post_execute' , _IP_REGISTERED )
180- except AttributeError :
181- raise NotImplementedError ("Can not unregister events "
182- "in IPython < 2.0" )
183- _IP_REGISTERED = None
184-
185- if _INSTALL_FIG_OBSERVER :
186- _INSTALL_FIG_OBSERVER = False
187-
188-
189111draw_all = _pylab_helpers .Gcf .draw_all
190112
191113
@@ -245,13 +167,11 @@ def isinteractive():
245167def ioff ():
246168 'Turn interactive mode off.'
247169 matplotlib .interactive (False )
248- uninstall_repl_displayhook ()
249170
250171
251172def ion ():
252173 'Turn interactive mode on.'
253174 matplotlib .interactive (True )
254- install_repl_displayhook ()
255175
256176
257177def pause (interval ):
@@ -532,16 +452,6 @@ def make_active(event):
532452 fig = figManager .canvas .figure
533453 fig .number = num
534454
535- # make sure backends (inline) that we don't ship that expect this
536- # to be called in plotting commands to make the figure call show
537- # still work. There is probably a better way to do this in the
538- # FigureManager base class.
539- if matplotlib .is_interactive ():
540- draw_if_interactive ()
541-
542- if _INSTALL_FIG_OBSERVER :
543- fig .stale_callback = _auto_draw_if_interactive
544-
545455 return figManager .canvas .figure
546456
547457
@@ -2494,13 +2404,6 @@ def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None,
24942404 sci (ret )
24952405 return ret
24962406
2497- # just to be safe. Interactive mode can be turned on without
2498- # calling `plt.ion()` so register it again here.
2499- # This is safe because multiple calls to `install_repl_displayhook`
2500- # are no-ops and the registered function respect `mpl.is_interactive()`
2501- # to determine if they should trigger a draw.
2502- install_repl_displayhook ()
2503-
25042407################# REMAINING CONTENT GENERATED BY boilerplate.py ##############
25052408
25062409
0 commit comments