I have three plots and I would like to stack them, shrink the bottom 2, and make sure they are vertically aligned. I can do one or the other, but not both. As you can see in plot 1, the plots are vertically aligned, but I need to shrink the bottom two; and in plot 2, the bottom two have been shrunk, but are not vertically aligned.
How can I shrink the bottom two plots and make sure all the plots are vertically aligned?
Here is an example:
ggplot:
library(gridExtra)
library(ggplot2)
library(cowplot)
a <- ggplot(data = diamonds, mapping = aes(y = carat, x = price)) + geom_line()
b <- ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar()
c <- ggplot(data = diamonds, mapping = aes(x = color)) + geom_bar()
Plot 1:
plot_grid(a, b, c, labels=c("", "", ""), ncol = 1, nrow = 3, align = "v")
Plot 2:
grid.arrange(a,b,c, ncol = 1, nrow = 3, widths = c(1), heights = c(1,.3,.3))
Try the
rel_heights
argument: