使用 ggpubr - R 标记每个图

Posted

技术标签:

【中文标题】使用 ggpubr - R 标记每个图【英文标题】:Label each plot using ggpubr - R 【发布时间】:2020-10-20 13:42:33 【问题描述】:

我使用 ggarange 将一组 R 图排列成一个,如何在每个子图的左上方将它们标记为 A、B 和 C?

代码:

library(ggplot2)
library(ggpubr)


# default ggplot2 theme
P1 <- ggplot(iris, aes(Sepal.Length, Petal.Width, color = Species)) + 
  geom_point()

P2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + 
  geom_point()

P3 <- ggplot(iris, aes(Petal.Length, Sepal.Width, color = Species)) + 
  geom_point()
 

ggarrange(P1, P2, P3,  ncol=3, nrow=1, common.legend = TRUE, legend="bottom")
          

【问题讨论】:

【参考方案1】:

使用标签

ggarrange(P1, P2, P3,  labels = c("A", "B", "C"),
          ncol = 3, nrow = 1, 
          common.legend = TRUE, legend = "bottom")

【讨论】:

以上是关于使用 ggpubr - R 标记每个图的主要内容,如果未能解决你的问题,请参考以下文章