Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Bokeh输出_文件未在html中显示_Python_Bokeh - Fatal编程技术网

Python Bokeh输出_文件未在html中显示

Python Bokeh输出_文件未在html中显示,python,bokeh,Python,Bokeh,我正在建立一个网页,其中有一些博克情节,并一直在使用Jupyter笔记本来建立情节。但是,现在我需要在html中显示绘图,而不是在笔记本中显示,但由于某些原因,绘图不显示。以下是从bokeh的页面上截取的一个非常简单的图: # prepare some data x = [1, 2, 3, 4, 5] y = [6, 7, 2, 4, 5] # output to static HTML file output_file("lines.html") # create a new plot

我正在建立一个网页,其中有一些博克情节,并一直在使用Jupyter笔记本来建立情节。但是,现在我需要在html中显示绘图,而不是在笔记本中显示,但由于某些原因,绘图不显示。以下是从bokeh的页面上截取的一个非常简单的图:


# prepare some data
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

# output to static HTML file
output_file("lines.html")

# create a new plot with a title and axis labels
p = figure(title="simple line example", x_axis_label='x', y_axis_label='y')

# add a line renderer with legend and line thickness
p.line(x, y, legend_label="Temp.", line_width=2)

# show the results
show(p)

当我运行代码时,会打开一个新选项卡,但它是空的。如果我运行
save
而不是
show
,打开文件时会出现相同的问题,因为文件是空的。

save
show
(在
output\u file
之后)对我都有效。在以下示例中,创建了文件
lines-a.html
lines-b.html

来自bokeh.plotting导入图的

从bokeh.io导入保存,输出_文件,显示
输出_文件(“lines-a.html”)
#准备一些数据
x=[1,2,3,4,5]
y=[6,7,2,4,5]
#创建带有标题和轴标签的新打印
p=图(title=“简单线示例”,x_轴标签='x',y_轴标签='y')
#添加带有图例和线条粗细的线条渲染器
p、 线条(x,y,图例_label=“Temp.”,线条宽度=2)
#显示结果
保存(p,“lines-b.html”,title=“Test”)
表演(p)

当我运行代码时,选项卡打开为空,保存的html文件也为空。我不知道这是怎么可能的?@andKaae我的所有文件都不是空的,都包含预期的数字。您是否在新的笔记本会话中完全运行了我的代码片段,而没有运行其他内容?如果是这样的话,我会怀疑你的配置有问题。是的,我试着在一个新的笔记本上运行它,结果是一样的。我很震惊可能是这样,你知道怎么解决吗?