作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在 Databricks 上使用 HoloViews 绘图或 Hvplot?
生成的图还应保持所有交互性。
最佳答案
Bokeh file_html
将返回 HTML+JS 代码以提供数据的交互式图表。总的 HTML 必须小于 20MB。您的数据需要内嵌到您的 HTML 中,否则您可能会遇到 CSRF 错误。确保您已安装 python holoviews
、bokeh
和 hvplot
包。示例:
import math
import numpy as np
import pandas as pd
import holoviews as hv
from bokeh.embed import components, file_html
from bokeh.resources import CDN
hv.extension('bokeh')
import hvplot
renderer = hv.renderer('bokeh').instance(fig='html', holomap='auto')
# see https://github.com/ioam/holoviews/issues/1819
def displayHoloviews(hv_plot, html_name="plot.html", width=1000, height=600, renderer=renderer):
plot = renderer.get_plot(hv_plot).state
setattr(plot, 'plot_width', width)
setattr(plot, 'plot_height', height)
displayHTML(file_html(plot, CDN, html_name))
index = pd.date_range('1/1/2000', periods=1000)
df = pd.DataFrame(np.random.randn(1000, 4), index=index, columns=list('ABCD')).cumsum()
displayHoloviews(hvplot.hvPlot(df).line(y=['A','B','C','D']))
关于python - 如何在 Databricks 上使用 HoloViews/hvPlot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61394775/
我是一名优秀的程序员,十分优秀!