Load numpy and matplotlib to work interactively. This function lets you activate pylab (matplotlib, numpy and interactive support) at any point during an IPython session. %pylab makes the following imports:: import numpy import matplotlib
(self, line='')
| 116 | ) |
| 117 | @magic_gui_arg |
| 118 | def pylab(self, line=''): |
| 119 | """Load numpy and matplotlib to work interactively. |
| 120 | |
| 121 | This function lets you activate pylab (matplotlib, numpy and |
| 122 | interactive support) at any point during an IPython session. |
| 123 | |
| 124 | %pylab makes the following imports:: |
| 125 | |
| 126 | import numpy |
| 127 | import matplotlib |
| 128 | from matplotlib import pylab, mlab, pyplot |
| 129 | np = numpy |
| 130 | plt = pyplot |
| 131 | |
| 132 | from IPython.display import display |
| 133 | from IPython.core.pylabtools import figsize, getfigs |
| 134 | |
| 135 | from pylab import * |
| 136 | from numpy import * |
| 137 | |
| 138 | If you pass `--no-import-all`, the last two `*` imports will be excluded. |
| 139 | |
| 140 | See the %matplotlib magic for more details about activating matplotlib |
| 141 | without affecting the interactive namespace. |
| 142 | """ |
| 143 | args = magic_arguments.parse_argstring(self.pylab, line) |
| 144 | if args.no_import_all is None: |
| 145 | # get default from Application |
| 146 | if Application.initialized(): |
| 147 | app = Application.instance() |
| 148 | try: |
| 149 | import_all = app.pylab_import_all |
| 150 | except AttributeError: |
| 151 | import_all = True |
| 152 | else: |
| 153 | # nothing specified, no app - default True |
| 154 | import_all = True |
| 155 | else: |
| 156 | # invert no-import flag |
| 157 | import_all = not args.no_import_all |
| 158 | |
| 159 | gui, backend, clobbered = self.shell.enable_pylab(args.gui, import_all=import_all) |
| 160 | self._show_matplotlib_backend(args.gui, backend) |
| 161 | print( |
| 162 | "%pylab is deprecated, use %matplotlib inline and import the required libraries." |
| 163 | ) |
| 164 | print("Populating the interactive namespace from numpy and matplotlib") |
| 165 | if clobbered: |
| 166 | warn("pylab import has clobbered these variables: %s" % clobbered + |
| 167 | "\n`%matplotlib` prevents importing * from pylab and numpy" |
| 168 | ) |
| 169 | |
| 170 | def _show_matplotlib_backend(self, gui, backend): |
| 171 | """show matplotlib message backend message""" |
nothing calls this directly
no test coverage detected