San*_*ord 2 python holoviews databricks hvplot
如何在 Databricks 上运行 HoloViews 图或 Hvplot?
生成的图还应该保持所有交互性。
Bokehfile_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']))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1363 次 |
| 最近记录: |