How to make a small multiples chart in R

An important principle in analyzing data is “overview first, zoom and filter, then details on demand” (quote: Ben Shneiderman)

In practice, this typically means starting at a high level with a single chart, and then “zooming into” the data by replicating that chart for specific subsets of the dataset.

And, even more valuable is being able to compare these multiple subsetted charts against each other.

This is where the “small multiple” design comes into play. (This is also known as the “trellis chart,” “lattice chart”).

Small Multiples: Comparing data across groups

As Hadley Wickham points out in his book ggplot2, the small multiples technique facilitates comparison by creating the same chart for multiple subsets of your data.

Tufte as well notes in Envisioning Information:

At the heart of quantitative reasoning is a single question: Compared to what? Small multiple designs, multivariate and data bountiful, answer directly by visually enforcing comparisons of changes, of the differences among objects, of the scope of alternatives. For a wide range of problems in data presentation, small multiples are the best design solution.”

The small multiples technique is a powerful data visualization method for comparing across groups or comparing over time.

In my mind, this is a vastly under-used technique, if for no other reason than the small multiples design is difficult to implement with most tools like Excel, SAS, and even Tableau.

In contrast, R’s GGPlot2 package makes small multiples extraordinarily easy to create.

Small Multiples in R (i.e., Faceting)

In R’s ggplot2 package, we call the small multiples technique faceting.

To illustrate the faceting technique in R, let’s imagine the following scenario:

You have 12 months of sales data for 3 separate sales regions and you want to do some data exploration.

You could start out by creating a line chart: