MCPcopy Index your code
hub / github.com/ipython/ipython / import_pylab

Function import_pylab

IPython/core/pylabtools.py:417–447  ·  view source on GitHub ↗

Populate the namespace with pylab-related values. Imports matplotlib, pylab, numpy, and everything from pylab and numpy. Also imports a few names from IPython (figsize, display, getfigs)

(user_ns, import_all=True)

Source from the content-addressed store, hash-verified

415
416
417def import_pylab(user_ns, import_all=True):
418 """Populate the namespace with pylab-related values.
419
420 Imports matplotlib, pylab, numpy, and everything from pylab and numpy.
421
422 Also imports a few names from IPython (figsize, display, getfigs)
423
424 """
425
426 # Import numpy as np/pyplot as plt are conventions we're trying to
427 # somewhat standardize on. Making them available to users by default
428 # will greatly help this.
429 s = ("import numpy\n"
430 "import matplotlib\n"
431 "from matplotlib import pylab, mlab, pyplot\n"
432 "np = numpy\n"
433 "plt = pyplot\n"
434 )
435 exec(s, user_ns)
436
437 if import_all:
438 s = ("from matplotlib.pylab import *\n"
439 "from numpy import *\n")
440 exec(s, user_ns)
441
442 # IPython symbols to add
443 user_ns['figsize'] = figsize
444 from IPython.display import display
445 # Add display and getfigs to the user's namespace
446 user_ns['display'] = display
447 user_ns['getfigs'] = getfigs
448
449
450# Determine if Matplotlib manages backends only if needed, and cache result.

Callers 1

enable_pylabMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…