如何获得交互式Holoviews图形以在Visual Studio中显示(不使用Jupyter)? [英] How do i get my interactive Holoviews graph to display in Visual Studio (without Jupyter)?

查看:475
本文介绍了如何获得交互式Holoviews图形以在Visual Studio中显示(不使用Jupyter)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Holoviews进行交互式绘图时,我主要使用Jupyter Notebook/Lab.
如何在不使用Visual Studio内部的Interactive Jupyter的情况下使Visual Studio显示交互式图形和面板?

I'm mainly using Jupyter Notebook / Lab when using Holoviews for interactive plotting.
How do I make Visual Studio display my interactive graphs and panels, without using the Interactive Jupyter inside Visual Studio?

推荐答案

最简单的解决方案是将bokeh设置为渲染器的后端,然后使用bokeh.render.show().这将在浏览器中打开您的全息视图图:

Easiest solution is to set bokeh as backend of the renderer and then use bokeh.render.show(). This will open your holoviews plot in the browser:

hv.extension('bokeh')
from bokeh.plotting import show

show(hv.render(your_holoviews_plot))

完整的示例:

# 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))

这篇关于如何获得交互式Holoviews图形以在Visual Studio中显示(不使用Jupyter)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆