1

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

enter image description here

Plot 2:

grid.arrange(a,b,c, ncol = 1, nrow = 3, widths = c(1), heights = c(1,.3,.3))

enter image description here

Vedda
  • 7,066
  • 6
  • 42
  • 77
  • 1
    Marking as a possible duplicate. See [example #1](http://stackoverflow.com/q/13294952/2572423), [example #2](http://stackoverflow.com/q/13656642/2572423), and [example #3](http://stackoverflow.com/q/15016995/2572423). – JasonAizkalns Jan 29 '16 at 19:00
  • 1
    Please include all `library` statements when posting a question. – G. Grothendieck Jan 29 '16 at 19:05

1 Answers1

6

Try the rel_heights argument:

plot_grid(a, b, c, ncol = 1, align = "v", rel_heights = c(3, 1, 1))
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341