python - 如何让我的交互式 Holoviews 图形显示在 Visual Studio(没有 Jupyter)中?
问题描述
在使用 Holoviews 进行交互式绘图时,我主要使用 Jupyter Notebook / Lab。
如何让 Visual Studio 显示我的交互式图形和面板,而不使用 Visual Studio 中的交互式 Jupyter?
解决方案
在 Visual Studio 中使用来自 Holoviews 等的交互式图表的一种方法是执行代码以在浏览器中显示图表(Holoviews 就是为此而设计的)。
下面的示例将您的 Holoviews 图形放在面板中并启动 Bokeh 服务器。
它会在您的浏览器上打开一个新选项卡并显示您的图表。
# library imports
import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('bokeh', logo=False)
import panel as pn
# create sample data
data = np.random.normal(size=[50, 2])
df = pd.DataFrame(data, columns=['col1', 'col2'])
# create holoviews graph
hv_plot = hv.Points(df)
# display graph in browser
# a bokeh server is automatically started
bokeh_server = pn.Row(hv_plot).show(port=12345)
# stop the bokeh server (when needed)
bokeh_server.stop()
推荐阅读
- cloud - CloudStack 无法添加主机
- swift - 如何获得最顶层的视图并使用它在 SwiftUI 中呈现特定视图?
- sql - SQL 在 2 个日期之间获取名称,但也保留任何以前的日期
- ios - 如何在 SwiftUI 中创建从登录视图到选项卡视图的过渡?
- javascript - 在 React Hooks useState() 中更改作为参数传递的类的数据
- java - Player*First*JoinEvent 我应该怎么做?
- vue.js - 在容器中放置 v-app-bar 内容有问题吗?
- sql - SQL 字节截断
- javascript - 如何使箭头键始终能够移动我的角色?
- java - Unable to get java command to use correct version of Java