我有一个字符串列表:
<section class="main">
<div class="container grid">
<div class="box_a b1">
<h2>What we do</h2>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Adipisci, commodi.</p>
<a href="#">Povezava nekam</a>
</div>
<div class="box_b b2">
<h2>How we do it</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In quibusdam iste, earum aut facilis nobis?</p>
<a href="#">Povezava nekam</a>
</div>
<div class="box_c b3">
<div class="post_top">
<a href="#">Povezava prispevka</a>
<h2>Nek zelo dolg naslov prispevka da bo zgledalo lepo</h2>
</div>
<div class="post_bottom">
<h2>Nek podnaslov</h2>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quisquam, placeat. Maiores omnis numquam error adipisci.</p>
</div>
</div>
<div class="box_a b4">
<a href="#">Povezava nekam</a>
<h2>Lorem Ipsum</h2>
<a href="#">Preberi več</a>
</div>
<div class="box_b b5">
<a href="#">Povezava nekam</a>
<h2>Nek srednje dolg naslov</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ut, neque.</p>
</div>
</div>
</section>
如何在Python中将其转换为旭日形图?
森伯斯特图按前四个单词显示问题的分布,弧长与包含该单词的问题数量成正比,白色区域表示贡献太小而无法显示。
({Image source->第5页,图3)
问题How to make a sunburst plot in R or Python?并没有对输入格式做任何假设,而Python答案则假设输入的格式完全不同。
答案 0 :(得分:0)
我建议使用R包ggsunburst https://github.com/didacs/ggsunburst
这可能是一个很好的起点。 data.txt文件包含示例中的前四个字
library(ggsunburst)
sb <- sunburst_data('data.txt', type = "lineage", sep = ' ')
sunburst(sb, node_labels = T, node_labels.min = 0)
使用https://conversationstartersworld.com/good-questions-to-ask/中问题的前四个词
sunburst(sb, node_labels = T, leaf_labels = F, node_labels.min = 5)
答案 1 :(得分:0)
扩展Jimmy Ata的answer,它指向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()