Reputation: 11
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
)
Upvotes: 0
Views: 1224
Reputation: 473
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)
Upvotes: 0
Reputation: 67
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.
Upvotes: 1