[我试图按父级然后按级别为sunburst着色,以使parent1和parent2为红色和蓝色,然后按级别向外渐变。
我似乎与sunburstcolorway
一起使用版面设计很接近,但按级别显示的颜色并不完全。目前,我对colorway的输入是为每个观察值指定的十六进制代码列表。
如果有一种方法可以为每个单独的部分指定颜色,那将是理想的。我似乎无法弄清楚,对此我很陌生
library(plotly)
clin2 <- data.frame(
stringsAsFactors = FALSE,
ids = c("MGH","CU","MGH - WT",
"CU - WT","MGH - KDM","CU - KDM","MGH - G2032R",
"MGH - S1986F","MGH - D2033N","CU - L1951R/L2026M"),
labels = c("Gainor<br>et al. 2017",
"McCoach<br>et al. 2018","ROS1<br>Extrinsic",
"ROS1<br>Extrinsic","ROS1<br>Intrinsic","ROS<br>Intrinsic","G2032R",
"S1986F","D2033N","L1951R/<br>L2026M"),
parents = c(NA,NA,"MGH","CU","MGH",
"CU","MGH - KDM","MGH - KDM","MGH - KDM","CU - KDM"),
values = c(17L, 12L, 8L, 11L, 9L, 1L, 7L, 1L, 1L, 1L),
colors = c("#3182bd", "#e6550d", "#9ecae1", "#fdae6b", "#9ecae1",
"#fdae6b", "#deebf7", "#deebf7", "#deebf7", "#fee6ce")
)
clin2_plot <- plot_ly(clin2, ids = ~ids, labels = ~labels, parents = ~parents,
values = ~values, type = 'sunburst', branchvalues = 'total'
) %>% layout(sunburstcolorway = clin2$colors)
clin2_plot
“ >>
提前感谢。
我正在尝试按父级然后按级别为森伯斯特着色,以使parent1和parent2为红色和蓝色,然后按级别向外渐变。我似乎与...
我编辑了您的代码以使其可复制。对我来说,它似乎工作正常。我添加了一条黑色痕迹-请检查以下内容: