X Tutup
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions IPython/core/pylabtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def mpl_execfile(fname,*where,**kw):
properly handle interactive rendering."""

import matplotlib
import matplotlib.pylab as pylab
import matplotlib.pyplot as plt

#print '*** Matplotlib runner ***' # dbg
# turn off rendering until end of script
Expand All @@ -168,9 +168,17 @@ def mpl_execfile(fname,*where,**kw):
safe_execfile(fname,*where,**kw)
matplotlib.interactive(is_interactive)
# make rendering call now, if the user tried to do it
if pylab.draw_if_interactive.called:
pylab.draw()
pylab.draw_if_interactive.called = False
if plt.draw_if_interactive.called:
plt.draw()
plt.draw_if_interactive.called = False

# re-draw everything that is stale
try:
da = plt.draw_all
except AttributeError:
pass
else:
da()

return mpl_execfile

Expand Down Expand Up @@ -297,12 +305,12 @@ def activate_matplotlib(backend):

# This must be imported last in the matplotlib series, after
# backend/interactivity choices have been made
import matplotlib.pylab as pylab
import matplotlib.pyplot as plt

pylab.show._needmain = False
plt.show._needmain = False
# We need to detect at runtime whether show() is called by the user.
# For this, we wrap it into a decorator which adds a 'called' flag.
pylab.draw_if_interactive = flag_calls(pylab.draw_if_interactive)
plt.draw_if_interactive = flag_calls(plt.draw_if_interactive)


def import_pylab(user_ns, import_all=True):
Expand Down
X Tutup