hs100
hs100

Reputation: 496

Label each plot using ggpubr - R

I aranged a set of R plots into one using ggarange, How can I label them A,B and C at the top left of each subplot?

Code:

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")
          

Upvotes: 1

Views: 719

Answers (1)

zx8754
zx8754

Reputation: 56159

Use labels:

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

enter image description here

Upvotes: 2

Related Questions