Facets

Learn about faceting and how to use it to create more descriptive visualizations.

We'll cover the following

Faceting is used when we’d like to split a particular visualization by the values of another variable. This will create multiple copies of the same type of plot with matching x and y axes, but whose content will differ.

Example

For example, suppose we’re interested in looking at how the histogram of hourly temperature recordings at the three NYC airports we saw before differed in each month. We can split this histogram by the 12 possible months in a given year. In other words, we’ll plot histograms of temp for each month separately. We do this by adding the facet_wrap(~ month) layer.

Get hands-on with 1200+ tech skills courses.