Chapter 19. Advanced graphics with ggplot2

 

This chapter covers

  • An introduction to the ggplot2 package
  • Using shape, color, and size to visualize multivariate data
  • Comparing groups with faceted graphs
  • Customizing ggplot2 plots

In previous chapters, you created a wide variety of general and specialized graphs (and had lots of fun in the process). Most were produced using R’s base graphics system. Given the diversity of methods available in R, it may not surprise you to learn that four separate and complete graphics systems are currently available.

In addition to base graphics, graphics systems are provided by the grid, lattice, and ggplot2 packages. Each is designed to expand on the capabilities of, and correct for deficiencies in, R’s base graphics system.

The grid graphics system provides low-level access to graphic primitives, giving programmers a great deal of flexibility in the creation of graphic output. The lattice package provides an intuitive approach for examining multivariate relationships through conditional one-, two-, or three-dimensional graphs called trellis graphs. The ggplot2 package provides a method of creating innovative graphs based on a comprehensive graphical “grammar.”

19.1. The four graphics systems in R

19.2. An introduction to the ggplot2 package

19.3. Specifying the plot type with geoms

19.4. Grouping

19.5. Faceting

19.6. Adding smoothed lines

19.7. Modifying the appearance of ggplot2 graphs

19.8. Saving graphs

19.9. Summary

sitemap