def install_repl_displayhook():
 global _IP_REGISTERED
 global _INSTALL_FIG_OBSERVER
 class _NotIPython(Exception, ):
  pass
 try:
  if (u'IPython' in sys.modules):
   from IPython import get_ipython
   ip = get_ipython()
   if (ip is None):
    raise _NotIPython()
   if _IP_REGISTERED:
    return
   def post_execute():
    if matplotlib.is_interactive():
     draw_all()
   try:
    ip.events.register(u'post_execute', post_execute)
   except AttributeError:
    ip.register_post_execute(post_execute)
   _IP_REGISTERED = post_execute
   _INSTALL_FIG_OBSERVER = False
   from IPython.core.pylabtools import backend2gui
   ipython_gui_name = backend2gui.get(get_backend())
   if ipython_gui_name:
    ip.enable_gui(ipython_gui_name)
  else:
   _INSTALL_FIG_OBSERVER = True
 except (ImportError, _NotIPython):
  _INSTALL_FIG_OBSERVER = True

def install_repl_displayhook ( ) : global _IP_REGISTERED global _INSTALL_FIG_OBSERVER class _NotIPython ( Exception , ) : pass try : if ( u'IPython' in sys . modules ) : from IPython import get_ipython ip = get_ipython ( ) if ( ip is None ) : raise _NotIPython ( ) if _IP_REGISTERED : return def post_execute ( ) : if matplotlib . is_interactive ( ) : draw_all ( ) try : ip . events . register ( u'post_execute' , post_execute ) except AttributeError : ip . register_post_execute ( post_execute ) _IP_REGISTERED = post_execute _INSTALL_FIG_OBSERVER = False from IPython . core . pylabtools import backend2gui ipython_gui_name = backend2gui . get ( get_backend ( ) ) if ipython_gui_name : ip . enable_gui ( ipython_gui_name ) else : _INSTALL_FIG_OBSERVER = True except ( ImportError , _NotIPython ) : _INSTALL_FIG_OBSERVER = True
install a repl display hook so that any stale figure are automatically redrawn when control is returned to the repl .