Skip to content
Browse files

Checkpoint

  • Loading branch information...
1 parent 2c6be75 commit d29192649956339af807d32003c5437eae100f98 @fperez committed Feb 1, 2012
Showing with 17 additions and 10 deletions.
  1. +4 −0 IPython/core/interactiveshell.py
  2. +13 −10 IPython/core/pylabtools.py
View
4 IPython/core/interactiveshell.py
@@ -396,6 +396,10 @@ def profile(self):
# Private interface
_post_execute = Instance(dict)
+ # The %pylab call can change the state of pylab
+ _pylab_backend = None
+ _pylab_gui = None
+
def __init__(self, config=None, ipython_dir=None, profile_dir=None,
user_module=None, user_ns=None,
custom_exceptions=((), None)):
View
23 IPython/core/pylabtools.py
@@ -210,22 +210,23 @@ def activate_matplotlib(backend):
"""Activate the given backend and set interactive to True."""
import matplotlib
- if backend.startswith('module://'):
- # Work around bug in matplotlib: matplotlib.use converts the
- # backend_id to lowercase even if a module name is specified!
- matplotlib.rcParams['backend'] = backend
- else:
- matplotlib.use(backend)
+ ## if backend.startswith('module://'):
+ ## # Work around bug in matplotlib: matplotlib.use converts the
+ ## # backend_id to lowercase even if a module name is specified!
+ ## matplotlib.rcParams['backend'] = backend
+ ## else:
+ ## matplotlib.use(backend)
matplotlib.interactive(True)
-
+ matplotlib.rcParams['backend'] = backend
+
# This must be imported last in the matplotlib series, after
# backend/interactivity choices have been made
import matplotlib.pylab as pylab
# XXX For now leave this commented out, but depending on discussions with
# mpl-dev, we may be able to allow interactive switching...
- #import matplotlib.pyplot
- #matplotlib.pyplot.switch_backend(backend)
+ import matplotlib.pyplot
+ matplotlib.pyplot.switch_backend(backend)
pylab.show._needmain = False
# We need to detect at runtime whether show() is called by the user.
@@ -328,7 +329,9 @@ def pylab_activate(user_ns, gui=None, import_all=True, shell=None):
"""
gui, backend = find_gui_and_backend(gui)
activate_matplotlib(backend)
- import_pylab(user_ns, import_all)
+ # Only call the imports
+ if shell._pylab_backend is None:
+ import_pylab(user_ns, import_all)
if shell is not None:
configure_inline_support(shell, backend, user_ns)

0 comments on commit d291926

Please sign in to comment.
Something went wrong with that request. Please try again.