如何解决如何将多个朝阳图绘制成一个图形?
考虑来自https://plotly.com/r/sunburst-charts/的示例,可以将多个旭日形图绘制到一个图中:
library(plotly)
d1 <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/coffee-flavors.csv')
d2 <- read.csv('https://raw.githubusercontent.com/plotly/datasets/718417069ead87650b90472464c7565dc8c2cb1c/sunburst-coffee-flavors-complete.csv')
fig <- plot_ly()
fig <- fig %>%
add_trace(
ids = d1$ids,labels = d1$labels,parents = d1$parents,type = 'sunburst',maxdepth = 2,domain = list(column = 0)
)
fig <- fig %>%
add_trace(
ids = d2$ids,labels = d2$labels,parents = d2$parents,maxdepth = 3,domain = list(column = 1)
)
fig <- fig %>%
layout(
grid = list(columns =2,rows = 1),margin = list(l = 0,r = 0,b = 0,t = 0),sunburstcolorway = c(
"#636efa","#EF553B","#00cc96","#ab63fa","#19d3f3","#e763fa","#FECB52","#FFA15A","#FF6692","#B6E880"
),extendsunburstcolors = TRUE)
fig
我遇到的问题是,我在隔离的函数中生成不同的旭日形图,我想随后将其绘制成一个图形。但是,此命令(以及plotly::subplot(p,p)
)似乎无效:
p <- plot_ly(
labels = c("Eve","Cain","Seth","Enos","Noam","Abel","Awan","Enoch","Azura"),parents = c("","Eve","Eve"),values = c(10,14,12,10,2,6,4,4),type = 'sunburst'
)
fig <- plot_ly()
fig <- fig %>%
add_trace(
p,domain = list(column = 0)
)
fig <- fig %>%
add_trace(
p,domain = list(column = 1)
)
fig <- fig %>%
layout(
grid = list(columns =2,t = 0))
fig
我在做什么错了?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。