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

Function activate_matplotlib

IPython/core/pylabtools.py:306–327  ·  view source on GitHub ↗

Activate the given backend and set interactive to True.

(backend)

Source from the content-addressed store, hash-verified

304
305
306def activate_matplotlib(backend):
307 """Activate the given backend and set interactive to True."""
308
309 import matplotlib
310 matplotlib.interactive(True)
311
312 # Matplotlib had a bug where even switch_backend could not force
313 # the rcParam to update. This needs to be set *before* the module
314 # magic of switch_backend().
315 matplotlib.rcParams['backend'] = backend
316
317 # Due to circular imports, pyplot may be only partially initialised
318 # when this function runs.
319 # So avoid needing matplotlib attribute-lookup to access pyplot.
320 from matplotlib import pyplot as plt
321
322 plt.switch_backend(backend)
323
324 plt.show._needmain = False
325 # We need to detect at runtime whether show() is called by the user.
326 # For this, we wrap it into a decorator which adds a 'called' flag.
327 plt.draw_if_interactive = flag_calls(plt.draw_if_interactive)
328
329
330def import_pylab(user_ns, import_all=True):

Callers

nothing calls this directly

Calls 1

flag_callsFunction · 0.90

Tested by

no test coverage detected