Then this should work:

```
library(ggplot2)
library(cowplot)

p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() p2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width * 1000)) + geom_point()

plot_grid(p1, p2, ncol = 1, align = "hv", rel_heights = c(2, 1), axis = "t")

p1 <- p1 + theme(
  axis.text.x = element_blank(),
  axis.title.x = element_blank(),
  axis.ticks.x = element_blank()
)

plot_grid(p1, p2, ncol = 1, align = "hv", rel_heights = c(2, 1), axis = "t")

# You can play around with ggplot2 plot.margin to further reduce the space
p1 <- p1 + theme(
  plot.margin = margin(b = -6)
)

p2 <- p2 + theme(
  plot.margin = margin(t = -6)
)

plot_grid(p1, p2, ncol = 1, align = "hv", rel_heights = c(2, 1), axis = "t")
```

Best,
Ulrik

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to