Book Image

ggplot2 Essentials

By : Donato Teutonico
Book Image

ggplot2 Essentials

By: Donato Teutonico

Overview of this book

Table of Contents (14 chapters)
ggplot2 Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Faceting


Faceting is a mechanism to automatically lay out multiple plots on one page. This functionality is quite nice and useful in many situations and, for this reason, we will venture a little deeper into it and look at some examples. As already mentioned, if you are familiar with other plotting packages, this functionality is very similar to the concept of panels in lattice.

The plot is realized with the faceting option by splitting the data into subsets, and each subset of data is represented in an individual plot. Nevertheless, the individual plots are formatted in an overall plot page with a header at the top or on the side of the panels, which identify the data represented in the subplot. Faceting is particularly useful if you need to have a first impression of how different data sets behaves or if the representation of the data should be separated for any reason.

There are two main ways to perform faceting in ggplot2: grid faceting and wrap faceting.

Grid faceting

This is probably the...