Composing Gadfly plots
In the Exploring data with Gadfly section of Chapter 5, Introducing the Grammar of Graphics, we saw how to create small multiples and horizontally stack plots. For the latter, we used the hstack
function, which takes a series of Gadfly
plots, and stacks them horizontally, creating one row and multiple columns. We can use the vstack
function to arrange the subplot vertically and create multiple rows. We can combine the result of vstack
using hstack
, or vice versa, to create a grid. However, it is also possible to use the gridstack
function for that. The input of gridstack
is a matrix of plots that indicates the position of each subplot in the grid.
In this section, we have noted the three main functions offered by Gadfly
to arrange multiple plots into a single figure. Let’s summarize what we’ve learned so far.