Facetting (ggplot)

Facetting is a process that combines data sub-setting and data visualization.

Data

The diamonds dataset that ships with ggplot.

Plot Syntax: facet_grid

Facets are multiple small plots, each representing a slice of data.  Facetting is a powerful data analysis and exploration tool.  facet_grid produces a lattice grid of plot panels with basic row and column identifiers.  

Plot70 Plot71 Plot72 Plot73

Plot Syntax: facet_wrap

facet_wrap takes a strip of plot panels and wraps them by row into a lattice.  Function arguments control the number of rows or columns that guide panel wrapping:

Plot76 Plot77

Aesthetics

The arguments to facet_grid that control plot aesthetics are:

The aesthetic arguments to facet_wrap are:

Modifying Label Text

Changes to panel label text are possible and require changes to the factors that comprise the input data set.  For example:

Modifying Label Formats

Label format changes require changes to theme formats, or the default formats behind ggplot.

Plot75

Back | Next

Leave a Reply

Your email address will not be published. Required fields are marked *

18 − 7 =