是否可以将joyplot作为面板添加到包含ggtree的图中,如these examples所示?喜悦图的例子是here。ggjoy facet with ggtree
我意识到我可以手动将joyplot的物种标签按照树尖标签的顺序放置,但我正在寻找自动解决方案。我想自动将joyplot行与树的提示相关联,类似于boxplot数据如何与提示标签相关联。
我认为Guangchuang瑜在上面的链接示例提供合适的数据:
require(ggtree)
require(ggstance)
# generate tree
tr <- rtree(30)
# create simple ggtree object with tip labels
p <- ggtree(tr) + geom_tiplab(offset = 0.02)
# Generate categorical data for each "species"
d1 <- data.frame(id=tr$tip.label, location=sample(c("GZ", "HK", "CZ"), 30, replace=TRUE))
#Plot the categorical data as colored points on the tree tips
p1 <- p %<+% d1 + geom_tippoint(aes(color=location))
# Generate distribution of points for each species
d4 = data.frame(id=rep(tr$tip.label, each=20),
val=as.vector(sapply(1:30, function(i)
rnorm(20, mean=i)))
)
# Create panel with boxplot of the d4 data
p4 <- facet_plot(p1, panel="Boxplot", data=d4, geom_boxploth,
mapping = aes(x=val, group=label, color=location))
plot(p4)
是否有可能到位箱线图的创建joyplot?
这里是演示数据集D4的上方快速joyplot代码:
require(ggjoy)
ggplot(d4, aes(x = val, y = id)) +
geom_joy(scale = 2, rel_min_height=0.03) +
scale_y_discrete(expand = c(0.01, 0)) + theme_joy()
我是新来GGPLOT2,ggtree和ggjoy所以我完全是在如何甚至开始这样做的损失。
你能提供一些合适的样本数据一起工作呢?粘贴到你的问题'dput(data_sample)' – eipi10
@ eipi10的输出我已经添加了一些由ggtree包的创建者编写的演示代码。我不知道'dput(data_sample)'指的是什么' – LCM