所以我有一个要在R中使用gglot2绘制的数据框。 让你了解我想要的 例子=
最后,谢谢大家阅读本文并帮助我。
答案 0 :(得分:0)
library(grid)
library(ggplotify)
library(cowplot)
library(tidyverse)
创建所有绘图(从plot_1到plot_n),例如:
plot_1 <- ggplot(data, aes(x=x, y=y, fill=value)) +
theme_classic() +
theme(text = element_text(size=24), axis.text.x = element_text(angle=0, hjust=0.5), legend.position="none") +
geom_bar(stat="identity", color="black", position=position_dodge()) +
geom_errorbar(aes(ymin=lwr.ci, ymax=upr.ci), width=.2,position=position_dodge(.9)) +
labs(y="ylab", x="xlab", subtitle = "subtitle") + scale_fill_manual(values=c("yellow", "blue"))
然后将它们放在一个简单的图中,如下所示:
pdf("many_plots_in_one.pdf")
plot_grid(plot_1, plot_2, plot_3, plot_4, plot_5, plot_6, ncol=3, labels=LETTERS[1:6])
dev.off()
答案 1 :(得分:0)
您可以分别绘制每个图。然后将多个图组合在一起:
library(patchwork)
combined_plot <- plot_AvsB + plot_AvsC + plot_AvsD + plot_AvsE + plot_layout(ncol = 2)
combined_plot