0

When I create a 12 panel figure (3 row by 4 col) using plot_grid in Cowplot, the labels in the third row do not align with others after "hjust = -6". Please help with the label positions in the third row. Thanks for the help.

PP1 <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) + 
geom_point(size = 2.5)
.
.
.

PP12 <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) + 
geom_point(size = 2.5)



plot3by4 <- plot_grid(PP1, PP2, PP3, PP4, 
                  PP5, PP6, PP7, PP8, PP9, PP10, PP11, PP12,
                  labels=c("A",   "B", "C", "D","E", "F", "G", "H", "I", "J", "K", "L"), 
                  ncol = 4, nrow = 4, align = 'v', 
                  hjust=-6, label_size=17)

save_plot("plot3by4.png", plot3by4,
      ncol = 4,
      nrow = 4, 
      base_aspect_ratio = 1
)

enter image description here

zx8754
  • 52,746
  • 12
  • 114
  • 209
Z.Chen
  • 11
  • 1

2 Answers2

1

hjust is for adjusting the plot label positions.

Use align = 'vh' (vertical and horizontal) to align the plots to one another.

labels = c(LETTERS[seq(1,12)]) is also good.

Sarah
  • 67
  • 1
  • 8
0

For anyone else who comes across this question, it seems that this question/problem was addressed on the cowplot git page with addition (creation?) of label_x = ...:

plot3by4 <- plot_grid(PP1, PP2, PP3, PP4, PP5, PP6, PP7, PP8, PP9, PP10, PP11, PP12,
     labels = "AUTO", ncol = 4, nrow = 3, label_x = .3, hjust = 0, label_size=17)
CzechInk
  • 443
  • 2
  • 13