##// END OF EJS Templates
adjust `import_pylab`...
MinRK -
Show More
@@ -251,7 +251,14 b' def activate_matplotlib(backend):'
251 251
252 252
253 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 263 # Import numpy as np/pyplot as plt are conventions we're trying to
257 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 270 "plt = pyplot\n"
264 271 )
265 272 exec s in user_ns
266
267 if import_all:
268 s = ("from matplotlib.pylab import *\n"
269 "from numpy import *\n")
270 exec s in user_ns
273
274 s = ("from matplotlib.pylab import *\n"
275 "from numpy import *\n")
276 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 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 326 shell._saved_rcParams[k] = pyplot.rcParams[k]
314 327 # load inline_rc
315 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 329 else:
319 330 from IPython.kernel.zmq.pylab.backend_inline import flush_figures
320 331 if flush_figures in shell._post_execute:
@@ -327,12 +338,6 b' def configure_inline_support(shell, backend, user_ns=None):'
327 338 fmt = cfg.figure_format
328 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 342 def pylab_activate(user_ns, gui=None, import_all=True, shell=None, welcome_message=False):
338 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 377 ' Using %s instead.' % (gui, pylab_gui_select))
373 378 gui, backend = find_gui_and_backend(pylab_gui_select)
374 379 activate_matplotlib(backend)
375 import_pylab(user_ns, import_all)
380 if import_all:
381 import_pylab(user_ns)
376 382 if shell is not None:
377 383 configure_inline_support(shell, backend, user_ns)
378 384 if welcome_message:
General Comments 0
You need to be logged in to leave comments. Login now