你好,我正在尝试通过将 100% 分成 2 个段来制作树形图,并使用以下代码分成 50% 和 50%:
labels = c("TOTAL","PARTE 1", "PARTE 2")
parents = c("","TOTAL","TOTAL")
values=c(100,50,50)
values = values
plot_ly(
type="treemap",
labels=labels,
parents=parents,
values=values,
textinfo="label+value+percent parent",
domain=list(column=0)
)
但是似乎被分成了 25%,这是为什么?
在第二步中,我想在一种漏斗上细分总数:
labels = c("TOTAL","PARTE 1", "PARTE 2","PARTE 1-A","PARTE 1-B", "PARTE 2-A")
parents = c("","TOTAL","TOTAL","PARTE 1","PARTE 1","PARTE 2")
values=c(100,50,50,25,25,50) %>% as.character()
values = values
plot_ly(
type="treemap",
labels=labels,
parents=parents,
values=values,
textinfo="label+value+percent parent",
domain=list(column=10)
)
但是 25/50 = 50%,并且在“PARTE 1”中显示 25%,而在“PARTE 2”中 50/50 = 100%,但它只显示 50%...出了什么问题?
此外,当我添加更多百分比时,其中任何一个都是我要查找的数字:
labels = c("TOTAL","PARTE 1", "PARTE 2","PARTE 1-A","PARTE 1-B", "PARTE 2-A")
parents = c("","TOTAL","TOTAL","PARTE 1","PARTE 1","PARTE 2")
values=c(100,50,50,25,25,50) %>% as.character()
values = values
plot_ly(
type="treemap",
labels=labels,
parents=parents,
values=values,
textinfo="label+value+percent parent+percent entry+percent root",
domain=list(column=10)
)
因为,例如“PARTE 1-A” = 25,即总数的 25%,等于 100,而“PARTE 1”的 50%,等于 50。并且这些数字都没有显示在这里。
有人可以帮忙吗?
我明白了!只需指定一个参数即可:
branchvalues="total"
labels = c("TOTAL","PARTE 1", "PARTE 2","PARTE 1-A","PARTE 1-B", "PARTE 2-A")
parents = c("","TOTAL","TOTAL","PARTE 1","PARTE 1","PARTE 2")
values=c(100,50,50,25,25,50) %>% as.character()
values = values
plot_ly(
type="treemap",
labels=labels,
parents=parents,
values=values,
branchvalues="total",
textinfo="label+value+percent parent+percent entry+percent root",
domain=list(column=10)
)