Bài viết phổ biến của tác giả
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我看过 zeppelin-plotly但它似乎太复杂了。另一件让我担心的事情是它涉及修改 zeppelin 的 .war
文件,我不想因为错误而破坏它。
还有其他方法可以将 Plotly 与 Zeppelin 一起使用吗?
câu trả lời hay nhất
sử dụng %angular
解释器功能解决了这个问题。这是让它工作的完整步骤
%sh pip install plotly
如果您有权访问终端,您也可以在终端上执行此操作
def plot(plot_dic, height=500, width=500, **kwargs):
kwargs['output_type'] = 'div'
plot_str = plotly.offline.plot(plot_dic, **kwargs)
print('%%angular %s ' % (height, width, plot_str))
这个自定义绘图函数使用角度解释器来绘制 html。它采用与 plotly.offline.plot
相同的参数加上一些额外的 div 尺寸参数(没有这些我的结果很糟糕)。像通常使用 plotly.offline.plot
一样使用它。
这些 plotly 是互动的!您不需要 iplot
,此处定义的 plot
函数也适用于 3D 交互式绘图。
%pyspark
nhập khẩu plotly
from plotly.graph_objs import Scatter, Layout
def plot(plot_dic, height=500, width=500, **kwargs):
kwargs['output_type'] = 'div'
plot_str = plotly.offline.plot(plot_dic, **kwargs)
print('%%angular %s ' % (height, width, plot_str))
plot({
"data": [
Scatter(x=[1, 2, 3, 4], y=[4, 5, 3, 7])
],
"layout": Layout(
title="hello world"
)
})
关于python - 如何在 Zeppelin 中使用 Plotly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37219069/
Tôi là một lập trình viên xuất sắc, rất giỏi!