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)
| 415 | |
| 416 | |
| 417 | def 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. |
no outgoing calls
no test coverage detected
searching dependent graphs…