我希望所有的哺乳动物都是黄色的,所有的爬行动物都是绿色的。我不能使用plot express,因为我的学校不允许。代码如下:
import plotly.graph_objs as go
fig = go.Figure(go.Sunburst(
labels=["Animal", "Reptile", "Lizard", "Snake", "Bird", "Salamander",
"Canary", "tweetle", "Mammal", "Equine", "Bovine", "Canine",
"Horse", "Zebra", "Cow", "Lassle", "Rintintin", "Bessle"],
parents=["", "Animal", "Reptile", "Reptile", "Reptile", "Lizard",
"Bird", "Canary", "Animal", "Mammal", "Mammal", "Mammal",
"Equine", "Equine", "Bovine", "Canine", "Canine", "Cow"],
))
fig.update_layout(margin = dict(t=0, l=0, r=0, b=0))
fig.show()
我认为有一个更好的方法,如果你能从你的数据中提取出
df
,但是从px
版本做一些反向工程,你可以试试相关问题 更多 >
编程相关推荐