Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created January 21, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/2cc2db62904947ba6147 to your computer and use it in GitHub Desktop.
Save whatalnk/2cc2db62904947ba6147 to your computer and use it in GitHub Desktop.
alline 2 plot , 2 row, ggplot2
[Align multiple ggplot2 graphs with a common x axis and different y axes, each with different y-axis labels.](https://gist.github.com/tomhopper/faa24797bb44addeba79)
`grid.draw()` is from grid package
* same x axis
* y values are different, so margin of y axis is different
* in result, width of plot area are changed
```{r}
gp1 <- ggplot(...)
gp2 <- ggplot(...)
grid.draw(rbind(ggplotGrob(gp1), ggplotGrob(gp2), size = "last"))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment