Chapter 16. Advanced graphics

 

This chapter covers

  • Trellis graphs and the lattice package
  • The grammar of graphs via ggplot2
  • Interactive graphics

In previous chapters, we created a wide variety of both 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 there are actually four separate and complete graphics systems currently available.

In addition to base graphics, we have graphics systems 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 1-, 2-, or 3-dimensional graphs called trellis graphs. The ggplot2 package provides a method of creating innovative graphs based on a comprehensive graphical “grammar.”

In this chapter, we’ll start with an overview of the four graphic systems. Then we’ll focus on graphs that can be generated with the lattice and ggplot2 packages. These packages greatly expand the range and quality of the graphs you can produce in R.

16.1. The four graphic systems in R

16.2. The lattice package

16.3. The ggplot2 package

16.4. Interactive graphs

16.5. Summary

sitemap