您唯一需要添加到代码中的是show(hv.render(your_holoviews_plot))
,如下所示:
import holoviews as hv
hv.extension('bokeh')
from bokeh.plotting import show
show(hv.render(your_holoviews_plot))
当您在 PyCharm(或任何其他 IDE)中运行脚本时,这将在浏览器中打开您的绘图。
它将散景设置为渲染器并使用 bokeh.plotting.show()在浏览器中打开绘图。
所以不需要去命令行等。
完整的工作示例代码:
# import libraries
import numpy as np
import pandas as pd
import hvplot.pandas
import holoviews as hv
# setting bokeh as backend
hv.extension('bokeh')
# going to use show() to open plot in browser
from bokeh.plotting import show
# create some sample data
data = np.random.normal(size=[50, 2])
df = pd.DataFrame(
data=data,
columns=['col1', 'col2'],
)
# using hvplot here to create a holoviews plot
# could have also just used holoviews itself
plot = df.hvplot(kind='scatter', x='col1', y='col2')
# use show() from bokeh
show(hv.render(plot))