3030 _matplotlib_imported = False
3131
3232__PLOTLY_OFFLINE_INITIALIZED = False
33- __PLOTLY_USE_CDN = False
3433
3534
3635def download_plotlyjs (download_url ):
@@ -53,14 +52,31 @@ def init_notebook_mode(connected=False):
5352 Initialize plotly.js in the browser if it hasn't been loaded into the DOM
5453 yet. This is an idempotent method and can and should be called from any
5554 offline methods that require plotly.js to be loaded into the notebook dom.
55+
56+ Keyword arguments:
57+
58+ connected (default=False) -- If True, the plotly.js library will be loaded
59+ from an online CDN. If False, the plotly.js library will be loaded locally
60+ from the plotly python package
61+
62+ Use `connected=True` if you want your notebooks to have smaller file sizes.
63+ In the case where `connected=False`, the entirety of the plotly.js library
64+ will be loaded into the notebook, which will result in a file-size increase
65+ of a couple megabytes. Additionally, because the library will be downloaded
66+ from the web, you and your viewers must be connected to the internet to be
67+ able to view charts within this notebook.
68+
69+ Use `connected=False` if you want you and your collaborators to be able to
70+ create and view these charts regardless of the availability of an internet
71+ connection. This is the default option since it is the most predictable.
72+ Note that under this setting the library will be included inline inside
73+ your notebook, resulting in much larger notebook sizes compared to the case
74+ where `connected=True`.
5675 """
5776 if not _ipython_imported :
5877 raise ImportError ('`iplot` can only run inside an IPython Notebook.' )
5978
6079 global __PLOTLY_OFFLINE_INITIALIZED
61- global __PLOTLY_USE_CDN
62- 63- __PLOTLY_USE_CDN = connected
6480
6581 if connected :
6682 # Inject plotly.js into the output cell
@@ -69,14 +85,15 @@ def init_notebook_mode(connected=False):
6985 '<script>'
7086 'requirejs.config({'
7187 'paths: { '
88+ # Note we omit the extension .js because require will include it.
7289 '\' plotly\' : [\' https://cdn.plot.ly/plotly-latest.min\' ]},'
7390 '});'
7491 'if(!window.Plotly) {{'
7592 'require([\' plotly\' ],'
7693 'function(plotly) {window.Plotly=plotly;});'
7794 '}}'
7895 '</script>'
79- )
96+ )
8097 else :
8198 # Inject plotly.js into the output cell
8299 script_inject = (
0 commit comments