Create a gist now

Instantly share code, notes, and snippets.

@schrob040 /mg-full.R
Last active Jul 17, 2017

What would you like to do?
# Convert the figures to grobs
mg_top_grob <- ggplotGrob(mg_top)
fb_grob <- ggplotGrob(fb)
mg_bottom_grob <- ggplotGrob(mg_bottom)
# Stick them together
gg <- ggplot() +
# First set the x and y axis values so we know what the ranges are
# in order to make it easier to place our facets
coord_equal(xlim = c(1, 10), ylim = c(1, 10), expand = F) +
# Then we place our facetsover one another using the coordinates we created
annotation_custom(mg_top_grob,
xmin = 1, xmax = 10, ymin = 5.5, ymax = 10) +
annotation_custom(fb_grob,
xmin = 3.5, xmax = 5.5, ymin = 7.2, ymax = 8.8) +
annotation_custom(mg_bottom_grob,
xmin = 1, xmax = 10, ymin = 1, ymax = 5.5)
# save
# DPI set very low because my internet is slow...
ggsave(plot = gg, filename = "../figures/mg_full.png", dpi = 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment