I was asked this question on Twitter and thought it might be good to have it here.
When making labeled, side-by-side plots with plot_grid()
, things work as expected for single-letter labels:
library(cowplot)
p1 <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) +
geom_density(alpha = 0.7) +
ggtitle("") + theme_minimal()
p2 <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) +
geom_density(alpha = 0.7) +
ggtitle("") +
scale_fill_grey() + theme_minimal()
plot_grid(p1, p2, labels = c("A", "B"))
However, if we're using longer strings as labels, the labels move to the right, and they move the more the longer the strings are:
plot_grid(p1, p2, labels = c("Density plot in color", "In gray"))
How can this be fixed?
Disclaimer: I'm the author of the package. Posting this here with answer in the hope it will be useful.