Chapter 5

The Grammar of Graphics: The ggplot2 Package

Chapter preview

This chapter describes how to produce plots using the ggplot2 package. There is a brief introduction to the concepts underlying the Grammar of Graphics paradigm as well as a description of the functions used to produce plots within this paradigm. The distinguishing feature of the ggplot2 package is its ability to produce a very wide range of different plots from a relatively small set of fundamental components. Because ggplot2 uses grid to draw plots, this chapter describes another way to produce a complete plot using the grid system.

The ggplot2 package provides an interpretation and extension of the ideas in Leland Wilkinson’s book The Grammar of Graphics. The ggplot2 ...

Get R Graphics, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.