This post
shows how to use the gridExtra
library to combine several
ggplot2
charts on the same figure. Several examples are
provided, illustrating several ways to split the graphing
window.
Mixing multiple graphs on the same page is a common practice. It allows to summarize a lot of information on the same figure, and is for instance widely used for scientific publication.
The gridExtra package makes it a breeze. It offers the
grid.arrange()
function that does exactly that. Its
nrow
argument allows to specify how to arrange the
layout.
For more complex layout, the arrangeGrob()
functions
allows to do some nesting. Here are 4 examples to illustrate how
gridExtra
works:
This document is a work of the statistics team in the Biostatistics and Medical Information Department at Saint-Louis Hospital in Paris (SBIM).
Based on The R Graph Gallery by Yan Holtz.