gpt4 book ai didi

bokeh - 使用 Zeppelin 的内联 Bokeh 图

转载 作者:行者123 更新时间:2023-12-05 03:12:02 25 4
gpt4 key购买 nike

是否可以使用 Pyspark 解释器在 Zeppelin 中内嵌显示 Bokeh 图表?

例如,在 Jupiter 中,这可以使用命令 output_notebook() 加载 Bokeh js 来完成。

这是一个生成简单折线图的示例。

from bokeh.io import output_notebook, show
from bokeh.plotting import figure

output_notebook()

# create a new plot
p = figure(plot_width=400, plot_height=400, title="Simple Line Plot")

# add a line renderer
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)

show(p) # show the results

最佳答案

实际上已注册发布此内容 - 我正在尝试使其正常工作,但遇到了一些有趣的问题。

看起来 Bokeh notebook 输出依赖于 IPython notebook,而 zeppelin 可能不是。

对于静态输出,许多 IPython notebook 常用的资源在 Zeppelin 中并不可用。

我在这里尝试一种可能最终会起作用的解决方法 - Zeppelin 有一些 Angular 标记可用于呈现 Bokeh HTML 文件。

我只是通过以下方式得到它:

s = "%html "
txt = open('log_lines.html').read()
s += txt
print(s)

编辑:看起来您仍然需要在图形/对象上调用 show() 来创建要显示的文件。这似乎不会产生错误,但我对 Bokeh 还是很陌生。

关于bokeh - 使用 Zeppelin 的内联 Bokeh 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35150382/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com