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)
| 328 | |
| 329 | |
| 330 | def import_pylab(user_ns, import_all=True): |
| 331 | """Populate the namespace with pylab-related values. |
| 332 | |
| 333 | Imports matplotlib, pylab, numpy, and everything from pylab and numpy. |
| 334 | |
| 335 | Also imports a few names from IPython (figsize, display, getfigs) |
| 336 | |
| 337 | """ |
| 338 | |
| 339 | # Import numpy as np/pyplot as plt are conventions we're trying to |
| 340 | # somewhat standardize on. Making them available to users by default |
| 341 | # will greatly help this. |
| 342 | s = ("import numpy\n" |
| 343 | "import matplotlib\n" |
| 344 | "from matplotlib import pylab, mlab, pyplot\n" |
| 345 | "np = numpy\n" |
| 346 | "plt = pyplot\n" |
| 347 | ) |
| 348 | exec(s, user_ns) |
| 349 | |
| 350 | if import_all: |
| 351 | s = ("from matplotlib.pylab import *\n" |
| 352 | "from numpy import *\n") |
| 353 | exec(s, user_ns) |
| 354 | |
| 355 | # IPython symbols to add |
| 356 | user_ns['figsize'] = figsize |
| 357 | from IPython.core.display import display |
| 358 | # Add display and getfigs to the user's namespace |
| 359 | user_ns['display'] = display |
| 360 | user_ns['getfigs'] = getfigs |
| 361 | |
| 362 | |
| 363 | def configure_inline_support(shell, backend): |