MCPcopy Create free account
hub / github.com/ipython/ipython / mpl_execfile

Function mpl_execfile

IPython/core/pylabtools.py:166–194  ·  view source on GitHub ↗

matplotlib-aware wrapper around safe_execfile. Its interface is identical to that of the :func:`execfile` builtin. This is ultimately a call to execfile(), but wrapped in safeties to properly handle interactive rendering.

(fname,*where,**kw)

Source from the content-addressed store, hash-verified

164 """
165
166 def mpl_execfile(fname,*where,**kw):
167 """matplotlib-aware wrapper around safe_execfile.
168
169 Its interface is identical to that of the :func:`execfile` builtin.
170
171 This is ultimately a call to execfile(), but wrapped in safeties to
172 properly handle interactive rendering."""
173
174 import matplotlib
175 import matplotlib.pyplot as plt
176
177 #print '*** Matplotlib runner ***' # dbg
178 # turn off rendering until end of script
179 is_interactive = matplotlib.rcParams['interactive']
180 matplotlib.interactive(False)
181 safe_execfile(fname,*where,**kw)
182 matplotlib.interactive(is_interactive)
183 # make rendering call now, if the user tried to do it
184 if plt.draw_if_interactive.called:
185 plt.draw()
186 plt.draw_if_interactive.called = False
187
188 # re-draw everything that is stale
189 try:
190 da = plt.draw_all
191 except AttributeError:
192 pass
193 else:
194 da()
195
196 return mpl_execfile
197

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected