MCPcopy Index your code
hub / github.com/plotly/plotly.py / init_notebook_mode

Function init_notebook_mode

plotly/offline/offline.py:251–290  ·  view source on GitHub ↗

Initialize plotly.js in the browser if it hasn't been loaded into the DOM yet. This is an idempotent method and can and should be called from any offline methods that require plotly.js to be loaded into the notebook dom. Keyword arguments: connected (default=False) -- If True,

(connected=False)

Source from the content-addressed store, hash-verified

249
250
251def init_notebook_mode(connected=False):
252 """
253 Initialize plotly.js in the browser if it hasn't been loaded into the DOM
254 yet. This is an idempotent method and can and should be called from any
255 offline methods that require plotly.js to be loaded into the notebook dom.
256
257 Keyword arguments:
258
259 connected (default=False) -- If True, the plotly.js library will be loaded
260 from an online CDN. If False, the plotly.js library will be loaded locally
261 from the plotly python package
262
263 Use `connected=True` if you want your notebooks to have smaller file sizes.
264 In the case where `connected=False`, the entirety of the plotly.js library
265 will be loaded into the notebook, which will result in a file-size increase
266 of a couple megabytes. Additionally, because the library will be downloaded
267 from the web, you and your viewers must be connected to the internet to be
268 able to view charts within this notebook.
269
270 Use `connected=False` if you want you and your collaborators to be able to
271 create and view these charts regardless of the availability of an internet
272 connection. This is the default option since it is the most predictable.
273 Note that under this setting the library will be included inline inside
274 your notebook, resulting in much larger notebook sizes compared to the case
275 where `connected=True`.
276 """
277 import plotly.io as pio
278
279 ipython = get_module("IPython")
280 if not ipython:
281 raise ImportError("`iplot` can only run inside an IPython Notebook.")
282
283 if connected:
284 pio.renderers.default = "plotly_mimetype+notebook_connected"
285 else:
286 pio.renderers.default = "plotly_mimetype+notebook"
287
288 # Trigger immediate activation of notebook. This way the plotly.js
289 # library reference is available to the notebook immediately
290 pio.renderers._activate_pending_renderers()
291
292
293def iplot(

Callers 1

enable_mpl_offlineFunction · 0.85

Calls 2

get_moduleFunction · 0.90

Tested by

no test coverage detected