【发布时间】:2021-05-04 17:14:52
【问题描述】:
我有一个用 ggplot2 制作的对图和一个条形图。我想知道是否可以将条形图嵌入到配对图的空间中。 它看起来像这样:
这是两个图的代码:
#pairs plot
pairs(pca$eigenvect[,1:4], labels = lbls, col=tab$pop,
lower.panel = NULL)
#barplot
ggplot(head_eigen, aes(x=pcindex, y = varexp), group=1) +
geom_bar(stat = "identity", width=0.6, fill="steelblue") +
theme_minimal() +
geom_point(color="darkblue")+
geom_text(aes(label=varexp), vjust=-0.3, size=3.5)+
geom_line(color="darkblue" ,group=1)+
ylim(0,5)+
ylab("Explained variance (%)") + xlab("Principle Component Number")
我已经尝试过 ggplot 函数 annotation_custom 和 cowplot 函数 ggdraw 但它们中的任何一个似乎都可以工作,因为对并不是真正的单一情节。
有什么想法吗?
提前致谢
【问题讨论】: