在交互式绘图散点图中包含电子表格

发布于 2025-01-09 00:46:45 字数 187 浏览 3 评论 0原文

最近,我一直在使用 plotly 生成漂亮的交互式散点图,人们可以在其中导航和搜索特定实例。然后我将结果保存在一个可以随时打开的 html 文件中。

我想知道是否可以包含一个电子表格(可能在同一个生成的 html 文件中),并附加点的表格描述(因此在 2D 绘图中,这些只是 XY 轴的坐标)。

Recently I've been using plotly to generate beautiful interactive scatterplots where one can navigate and search for specific instances. Then I've saved the result in a html file that can be opened anytime.

I'm wondering if it's possible to include a spreadsheet (potentially in the same generated html file) with attached tabular descriptions of the points (so having 2D plot, these would simply be coordinates of XY axes).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黒涩兲箜 2025-01-16 00:46:45

您可以使用 go.Table

go.Table 提供了一个 Table 对象,用于查看详细数据。数据排列在行和列的网格中。大多数样式可以为标题、列、行或单个单元格指定。

如果您的散点图和表格轨迹均属于同一图窗,则当您将图窗写入 html 文件时,两条轨迹都会显示。

from plotly.subplots import make_subplots
import plotly.graph_objects as go

x_values = [1, 2, 3]
y_values = [1, 3, 5]

fig = make_subplots(
    rows=2,
    cols=1,
    specs=[[{"type": "xy"}], [{"type": "domain"}]]
)

fig.add_trace(go.Scatter(x=x_values, y=y_values), row=1, col=1)
fig.add_trace(go.Table(header=dict(values=['X', 'Y']), cells=dict(values=[x_values, y_values])), row=2, col=1)

fig.write_html("demo.html")

结果

You could use go.Table

go.Table provides a Table object for detailed data viewing. The data are arranged in a grid of rows and columns. Most styling can be specified for header, columns, rows or individual cells.

If you have a scatter and a table trace that are both part of the same figure, both traces will show up when you write the figure to an html file.

from plotly.subplots import make_subplots
import plotly.graph_objects as go

x_values = [1, 2, 3]
y_values = [1, 3, 5]

fig = make_subplots(
    rows=2,
    cols=1,
    specs=[[{"type": "xy"}], [{"type": "domain"}]]
)

fig.add_trace(go.Scatter(x=x_values, y=y_values), row=1, col=1)
fig.add_trace(go.Table(header=dict(values=['X', 'Y']), cells=dict(values=[x_values, y_values])), row=2, col=1)

fig.write_html("demo.html")

result

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文