我正在尝试从jupyter内核(基于ProcessMetaKernel)创建图并在jupyter笔记本中显示图。
我的Jupyter内核代码是
class MyKernel(ProcessMetaKernel):
def do_execute_direct(self, code, silent=True):
import plotly
import plotly.graph_objs as go
plot_div=plotly.offline.plot({"data": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],"layout": go.Layout(title="hello world")}, auto_open=False, output_type='div',include_plotlyjs=True)
self.Display(HTML(data=plot_div))
return code
预期结果:在笔记本中显示的情节
实际结果:未显示图,在浏览器控制台中出现以下错误消息
未捕获的ReferenceError:未定义情节
at <anonymous>:7:21
at m (jquery.min.js:2)
at Re (jquery.min.js:2)
at w.fn.init.append (jquery.min.js:2)
at OutputArea._safe_append (outputarea.js:457)
at OutputArea.append_display_data (outputarea.js:660)
at OutputArea.append_output (outputarea.js:346)
at OutputArea.handle_output (outputarea.js:257)
at output (codecell.js:395)
at Kernel._handle_output_message (kernel.js:1196)