Skip to content

Instantly share code, notes, and snippets.

@kohske
Created December 12, 2017 09:53
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 kohske/266247e9d6f0b7a5b9a2fa20050dfaf4 to your computer and use it in GitHub Desktop.
Save kohske/266247e9d6f0b7a5b9a2fa20050dfaf4 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(gtable)
a = ggplot(data=diamonds, aes(x=price)) + geom_histogram()
b = ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width)) + geom_point()
agg = ggplot_gtable(ggplot_build(a))
bgg = ggplot_gtable(ggplot_build(b))
g = gtable(width=unit(c(0.3, 0.5), "null"), height = unit(1, "null"))
g = gtable_add_grob(g, agg, 1,1)
g = gtable_add_grob(g, agg, 1,2)
plot(g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment