我使用PLOT_ly像以前使用Adobe Illustrator所做的那样,将我的数据可视化为SunBurst,但是未能同样地给数据段上色.
以下是代码( colored颜色 代码是随机的):
library(plotly)
tab <- data.frame(
labels = c("Total", "Planerlöse", "Abgeltung", "Bund", "Kanton Thurgau", "Kanton Thurgau Netto", "Gemeinden" ),
parents = c("", "Total", "Total", "Abgeltung", "Abgeltung", "Kanton Thurgau", "Kanton Thurgau"),
values = c(100, 46,54, 23.76, 30.24, 20.26, 9.97),
colors=c("#f28f1c", "#fef4e8", "#2771b0", "#e9f1f7",
"#b5b5b5", "#787878", "#333333"),
type = 'sunburst',
branchvalues = 'total'
)
fig <- plot_ly(tab, labels = ~labels, parents = ~parents,
values = ~values, colors=colors, type = 'sunburst', branchvalues = 'total'
)
fig
And here the original plot I'd like to replicate:
感谢您的建议和帮助!