Show More
@@ -251,7 +251,14 b' def activate_matplotlib(backend):' | |||||
251 |
|
251 | |||
252 |
|
252 | |||
253 | def import_pylab(user_ns, import_all=True): |
|
253 | def import_pylab(user_ns, import_all=True): | |
254 | """Import the standard pylab symbols into user_ns.""" |
|
254 | """Populate the namespace with pylab-related values. | |
|
255 | ||||
|
256 | Imports matplotlib, pylab, numpy, and everything from pylab and numpy. | |||
|
257 | ||||
|
258 | Also imports a few names from IPython (figsize, display, getfigs) | |||
|
259 | ||||
|
260 | The import_all parameter is included for backward compatibility, but ignored. | |||
|
261 | """ | |||
255 |
|
262 | |||
256 | # Import numpy as np/pyplot as plt are conventions we're trying to |
|
263 | # Import numpy as np/pyplot as plt are conventions we're trying to | |
257 | # somewhat standardize on. Making them available to users by default |
|
264 | # somewhat standardize on. Making them available to users by default | |
@@ -263,11 +270,17 b' def import_pylab(user_ns, import_all=True):' | |||||
263 | "plt = pyplot\n" |
|
270 | "plt = pyplot\n" | |
264 | ) |
|
271 | ) | |
265 | exec s in user_ns |
|
272 | exec s in user_ns | |
266 |
|
273 | |||
267 | if import_all: |
|
274 | s = ("from matplotlib.pylab import *\n" | |
268 |
|
|
275 | "from numpy import *\n") | |
269 | "from numpy import *\n") |
|
276 | exec s in user_ns | |
270 | exec s in user_ns |
|
277 | ||
|
278 | # IPython symbols to add | |||
|
279 | user_ns['figsize'] = figsize | |||
|
280 | from IPython.core.display import display | |||
|
281 | # Add display and getfigs to the user's namespace | |||
|
282 | user_ns['display'] = display | |||
|
283 | user_ns['getfigs'] = getfigs | |||
271 |
|
284 | |||
272 |
|
285 | |||
273 | def configure_inline_support(shell, backend, user_ns=None): |
|
286 | def configure_inline_support(shell, backend, user_ns=None): | |
@@ -313,8 +326,6 b' def configure_inline_support(shell, backend, user_ns=None):' | |||||
313 | shell._saved_rcParams[k] = pyplot.rcParams[k] |
|
326 | shell._saved_rcParams[k] = pyplot.rcParams[k] | |
314 | # load inline_rc |
|
327 | # load inline_rc | |
315 | pyplot.rcParams.update(cfg.rc) |
|
328 | pyplot.rcParams.update(cfg.rc) | |
316 | # Add 'figsize' to pyplot and to the user's namespace |
|
|||
317 | user_ns['figsize'] = pyplot.figsize = figsize |
|
|||
318 | else: |
|
329 | else: | |
319 | from IPython.kernel.zmq.pylab.backend_inline import flush_figures |
|
330 | from IPython.kernel.zmq.pylab.backend_inline import flush_figures | |
320 | if flush_figures in shell._post_execute: |
|
331 | if flush_figures in shell._post_execute: | |
@@ -327,12 +338,6 b' def configure_inline_support(shell, backend, user_ns=None):' | |||||
327 | fmt = cfg.figure_format |
|
338 | fmt = cfg.figure_format | |
328 | select_figure_format(shell, fmt) |
|
339 | select_figure_format(shell, fmt) | |
329 |
|
340 | |||
330 | # The old pastefig function has been replaced by display |
|
|||
331 | from IPython.core.display import display |
|
|||
332 | # Add display and getfigs to the user's namespace |
|
|||
333 | user_ns['display'] = display |
|
|||
334 | user_ns['getfigs'] = getfigs |
|
|||
335 |
|
||||
336 |
|
341 | |||
337 | def pylab_activate(user_ns, gui=None, import_all=True, shell=None, welcome_message=False): |
|
342 | def pylab_activate(user_ns, gui=None, import_all=True, shell=None, welcome_message=False): | |
338 | """Activate pylab mode in the user's namespace. |
|
343 | """Activate pylab mode in the user's namespace. | |
@@ -372,7 +377,8 b' def pylab_activate(user_ns, gui=None, import_all=True, shell=None, welcome_messa' | |||||
372 | ' Using %s instead.' % (gui, pylab_gui_select)) |
|
377 | ' Using %s instead.' % (gui, pylab_gui_select)) | |
373 | gui, backend = find_gui_and_backend(pylab_gui_select) |
|
378 | gui, backend = find_gui_and_backend(pylab_gui_select) | |
374 | activate_matplotlib(backend) |
|
379 | activate_matplotlib(backend) | |
375 | import_pylab(user_ns, import_all) |
|
380 | if import_all: | |
|
381 | import_pylab(user_ns) | |||
376 | if shell is not None: |
|
382 | if shell is not None: | |
377 | configure_inline_support(shell, backend, user_ns) |
|
383 | configure_inline_support(shell, backend, user_ns) | |
378 | if welcome_message: |
|
384 | if welcome_message: |
General Comments 0
You need to be logged in to leave comments.
Login now