将Plotly html嵌入jupyter笔记本时出现Javascript错误

时间:2017-01-07 20:05:32

标签: python jupyter-notebook plotly

我试图将HTML从plotly嵌入到Jupyter笔记本中。这是HTML

<html>
<head>
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
  <div id="7979e646-13e6-4f44-8d32-d8effc3816df" style="height: 525; width: 100%;" class="plotly-graph-div"></div><script type="text/javascript">window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL="https://plot.ly";Plotly.newPlot("7979e646-13e6-4f44-8d32-d8effc3816df", [{"x": [1, 2, 3], "y": [3, 1, 6]}], {}, {"showLink": false, "linkText": ""})</script>
</body>
</html>

如果我把它放在普通的HTML文件中并在浏览器中打开它,它就可以了。另一方面,如果我将它放在Jupyter的%%html单元格中,或者如果我使用display(HTML(html_string))模块中的IPython.display,我会收到此错误:

Javascript error adding output!
ReferenceError: Plotly is not defined
See your browser Javascript console for more details.

导致这种情况的原因是什么?

0 个答案:

没有答案