我正在尝试使用plotly
创建朝阳图,但是它返回一个空白图。我的数据集包含的货币信息与下面类似(除了更多行):
df <- data.frame(
MainGroup = c("A", "A","A"),
Currency = c("USD","EUR","GBP"),
Percent = c(90,5,5),
Category = c("USD","Other","Other"),
stringsAsFactors = FALSE)
Category
基于Percent
列:小于10的任何内容都将归类为“其他”。我尝试了plot_ly(df, labels = ~Currency, parents = ~Category, values = ~Percent, type = 'sunburst')
,但返回了空白图表。我想创建一个像这样的图表:
答案 0 :(得分:0)
df <- data.frame(
MainGroup = c("A", "A","A"),
Currency = c("USDollars","EUR","GBP"),
Percent = c(90,5,5),
Category = c("USD","Other","Other"),
stringsAsFactors = FALSE)
plot_ly(labels = c(" ", "USD","Other",df$Currency), parents = c(""," "," ",df$Category), values = c(100,90,10,df$Percent), type = 'sunburst',
branchvalues='total')
这里有多个问题(我不得不说这些朝阳图很棘手):
Other
没有父母USD
,这是指定父母的问题,我将其中一个更改为USDollars
branchvalues='total'