如何从Plotly Sunburst图表中检索值?
Plotly Sunburst Charts 非常适合可视化层次数据。是否可以将图表中显示的值检索到字典或数组之类的内容中?
具体地说,假设以下数据框:
Att1 Att2
A C
A D
B D
B D
B C
px.sunburst(数据,['att1','att2'])
将生成一个图表,该图表在最内部的环中具有a
a <的值2 /code>和3用于
b
。然后,对于a
,它将指示有1 c
和1 d
。同样,对于b
,它将指示2 d
和1 c
。所有这些数字都是我想要检索的数字。情节有这样的功能吗?还是我最好的选择是data.groupby
迭代?
Plotly sunburst charts are great for visualizing hierarchical data. Is it possible to retrieve the values shown in the chart into a dictionary, or an array or something?
Concretely, assume the following dataframe:
Att1 Att2
A C
A D
B D
B D
B C
px.sunburst(data, ['Att1', 'Att2'])
will generate a chart that in the most inner ring has the value 2 for A
and 3 for B
. Then for A
, it will indicate there is 1 C
and 1 D
. Similarly, for B
it will indicate 2 D
and 1 C
. All those numbers are the ones I am looking to retrieve. Does plotly have such functionality? or is my best bet to use data.groupby
iteratively?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以访问来自图的基础数据,并且可以找到详细信息在Plotly 和总结下面...
有几个选项可用...
图。Show(“ JSON”)
如果您在笔记本print(Fig)
是我的方法中,则是我的hany。此绘图示例:
print(fig)
将返回:然后有了一些元组知识,您可以提取一些信息,例如...
print(图.data [0] .Labels)。
将返回:The underlying data from a figure can be accessed and the details can be found here at plotly and summarized below...
Several options are available...
fig.show("json")
is pretty hany if you're in a notebookprint(fig)
is my go to methodSo for this plotly example:
print(fig)
will return:And then with some knowledge of tuples you can extract some info, for example...
print(fig.data[0].labels)
will return: