def import_pylab(user_ns, import_all=True):
 s = 'import numpy\nimport matplotlib\nfrom matplotlib import pylab, mlab, pyplot\nnp = numpy\nplt = pyplot\n'
 exec s in user_ns
 if import_all:
  s = 'from matplotlib.pylab import *\nfrom numpy import *\n'
  exec s in user_ns
 user_ns['figsize'] = figsize
 from IPython.core.display import display
 user_ns['display'] = display
 user_ns['getfigs'] = getfigs

def import_pylab ( user_ns , import_all = True ) : s = 'import numpy\nimport matplotlib\nfrom matplotlib import pylab, mlab, pyplot\nnp = numpy\nplt = pyplot\n' exec s in user_ns if import_all : s = 'from matplotlib.pylab import *\nfrom numpy import *\n' exec s in user_ns user_ns [ 'figsize' ] = figsize from IPython . core . display import display user_ns [ 'display' ] = display user_ns [ 'getfigs' ] = getfigs
populate the namespace with pylab-related values .