python - 如何从 Python 中的字符串列表制作旭日图?

标签 python data-visualization sunburst-diagram

我有一个字符串列表:

How many glasses are on the tab ?
What does the sign say ?
Has the pizza been baked ?
Do you think the boy on the ground has broken legs ?
Is this man crying ?
How many pickles are on the plate ?
What is the shape of the plate?
…

如何在 Python 中将其转换为旭日图?

旭日图按前四个词显示问题的分布,弧长与包含该词的问题数量成正比,白色区域是贡献太小而无法显示的词。

enter image description here

( Image source -> 第 5 页,图 3)

问题How to make a sunburst plot in R or Python?不对输入格式做出任何假设,Python 答案假设输入具有非常不同的格式。

最佳答案

扩展 Jimmy Ataanswer ,它指向 Python plotly 包:


您可以使用 https://plotly.com/python/sunburst-charts/ :

来自同一页面的示例:

# From https://plotly.com/python/sunburst-charts/
import plotly.express as px
data = dict(
    character=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
    parent=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ],
    value=[10, 14, 12, 10, 2, 6, 6, 4, 4])

fig =px.sunburst(
    data,
    names='character',
    parents='parent',
    values='value',
)
fig.show()

enter image description here

关于python - 如何从 Python 中的字符串列表制作旭日图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54997495/

相关文章:

python - 注释栏时无法更改宽度

pandas - matplotlib Pandas : Change width between datapoints based on another columns value

pandas - 绘图图表的问题

javascript - 如何将我的数据转换成适合 d3.js sunburst 的格式?

javascript - D3 : Rotating labels in the third and fourth quad in sunburst example

python - 如何删除行 [DEBUG] pip.vcs : Registered VCS backend: *** from log file

python 3.3套接字类型错误

python - pyspark 试图检索具有相同 id 的行

javascript - 使用 D3 动态选择数据源创建旭日图

python - 如何更改 re.sub 中的十进制数的十六进制数