[英]Plotly treemap data structure?
I hardly try to build a treemap with plotly.我几乎没有尝试用 plotly 构建树形图。 The main difficulty I have is that the sub-categories don't fullfill the map.我遇到的主要困难是子类别没有填满 map。 I think there is a problem in my data strucure.我认为我的数据结构存在问题。 Thanks for any idea you could have感谢您的任何想法
My source dataframe looks like this:我的源 dataframe 看起来像这样:
id parent value color
0 F A1 20 0.298782
1 F A2 10 0.030511
2 F B1 35 0.562464
3 F B2 45 0.778931
4 F C1 30 0.308459
5 F C2 46 0.505771
6 M A1 24 0.242964
7 M A2 6 0.604043
8 M B1 24 0.279880
9 M B2 57 0.269249
10 M C1 82 0.914589
11 M C2 61 0.827076
12 A1 Pat A 44 0.896741
13 A2 Pat B 16 0.112626
14 B2 Pat A 102 0.024187
15 B1 Pat B 59 0.462012
16 C1 Pat A 112 0.003501
17 C2 Pat B 107 0.614476
18 Pat A total 258 0.150514
19 Pat B total 182 0.698287
20 total NaN 440 0.744805
I used the following code:我使用了以下代码:
fig = go.Figure(go.Treemap(
ids=df_all_trees['id'],
labels=df_all_trees['id'],
parents=df_all_trees['parent'],
values=df_all_trees['value'],
#branchvalues='total',
marker=dict(
colors=df_all_trees['value'],
colorscale='RdBu',
cmid=average_score),
hovertemplate='<b>%{label} </b> <br> Sales: %{value}<br> Success rate: %{color:.2f}',
name=''
))
fig.show()
and obtain something like this:并获得这样的东西:
What I would like: something "fully mapped" like this:我想要什么:像这样“完全映射”的东西:
Seems to be only the #branchvalues='total' to decoment.似乎只有 #branchvalues='total' 才能减分。 Hope nobody has wasted time with this.希望没有人在这件事上浪费时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.