8000 Merge pull request #9998 from tacaswell/mnt_remove_unneeded_pylab_imp… · ipython/ipython@b041e69 · GitHub
[go: up one dir, main page]

Skip to content

Commit b041e69

Browse files
authored
Merge pull request #9998 from tacaswell/mnt_remove_unneeded_pylab_imports
Mnt remove unneeded pylab imports
2 parents 299986a + 7bca352 commit b041e69

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def mpl_execfile(fname,*where,**kw):
162162
properly handle interactive rendering."""
163163

164164
import matplotlib
165-
import matplotlib.pylab as pylab
165+
import matplotlib.pyplot as plt
166166

167167
#print '*** Matplotlib runner ***' # dbg
168168
# turn off rendering until end of script
@@ -171,9 +171,17 @@ def mpl_execfile(fname,*where,**kw):
171171
safe_execfile(fname,*where,**kw)
172172
matplotlib.interactive(is_interactive)
173173
# make rendering call now, if the user tried to do it
174-
if pylab.draw_if_interactive.called:
175-
pylab.draw()
176-
pylab.draw_if_interactive.called = False
174+
if plt.draw_if_interactive.called:
175+
plt.draw()
176+
plt.draw_if_interactive.called = False
177+
178+
# re-draw everything that is stale
179+
try:
180+
da = plt.draw_all
181+
except AttributeError:
182+
pass
183+
else:
184+
da()
177185

178186
return mpl_execfile
179187

@@ -301,12 +309,12 @@ def activate_matplotlib(backend):
301309

302310
# This must be imported last in the matplotlib series, after
303311
# backend/interactivity choices have been made
304-
import matplotlib.pylab as pylab
312+
import matplotlib.pyplot as plt
305313

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

311319

312320
def import_pylab(user_ns, import_all=True):
0