File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 19
19
PLOTLY_OFFLINE_BUNDLE = os .path .join (PLOTLY_OFFLINE_DIRECTORY ,
20
20
'plotly-ipython-offline-bundle.js' )
21
21
22
+ __PLOTLY_OFFLINE_INITIALIZED = False
23
+
22
24
23
25
def download_plotlyjs (download_url ):
24
26
if not os .path .exists (plotlyjs_path ):
@@ -55,13 +57,24 @@ def init_notebook_mode():
55
57
56
58
.format (source_path = PLOTLY_OFFLINE_BUNDLE ))
57
59
60
+ global __PLOTLY_OFFLINE_INITIALIZED
61
+ __PLOTLY_OFFLINE_INITIALIZED = True
58
62
display (HTML ('<script type="text/javascript">' +
59
63
open (PLOTLY_OFFLINE_BUNDLE ).read () + '</script>' ))
60
64
61
65
62
66
def iplot (figure_or_data , show_link = True , link_text = 'Export to plot.ly' ):
63
67
"""
64
68
"""
69
+ if not __PLOTLY_OFFLINE_INITIALIZED :
70
+ raise exceptions .PlotlyError ('\n ' .join ([
71
+ 'Plotly Offline mode has not been initialized in this notebook. '
72
+ 'Run: ' ,
73
+ '' ,
74
+ 'import plotly' ,
75
+ 'plotly.offline.init_notebook_mode() '
76
+ '# run at the start of every ipython notebook' ,
77
+ ]))
65
78
from IPython .display import HTML , display
66
79
if isinstance (figure_or_data , dict ):
67
80
data = figure_or_data ['data' ]
You can’t perform that action at this time.
0 commit comments