by Paul Murrell
A book on the core graphics facilities of the R language and environment for statistical computing and graphics (Chapman & Hall/CRC, November 2018).
A link to the publisher's web page for the book.
A list of Updates.
A list of Errata.
R code for figures:
- Chapter 1: An Introduction to R Graphics
- Chapter 2: Simple Usage of Traditional Graphics
- Chapter 3: Customising Traditional Graphics
- Chapter 4: Trellis Graphics: The lattice Package
- Chapter 5: The Grammar of Graphics: The ggplot2 Package
- Chapter 6: The Grid Graphics Model
- Chapter 7: The Grid Graphics Object Model
- Chapter 8: Developing New Graphics Functions and Objects
- Chapter 9: Graphics Formats
- Chapter 10: Graphical Parameters
- Chapter 11: Importing Graphics
- Chapter 12: Combining Graphics Systems
- Chapter 13: Advanced Graphics
An R package called "RGraphics" is available from CRAN. This package contains: data sets used in the book (and not available in other existing packages); functions to reproduce the figures in the book, e.g., figure1.1(); and function, method, and class definitions from Chapter 8.
NOTE: versions 1.* and 2.* of the 'RGraphics' package correspond to the first and second editions of R Graphics, respectively. For this Third Edition, you need at least version 3.0 of the 'RGraphics' package.
NOTE:
The R code presented in these pages is the R code actually used
to produce the Figures in the book. There will be differences compared to
the code chunks shown in the text of the book, but in most cases the
differences will be that these pages contain additional code
to lay out multiple plots on a
single "page".
Some figures have been fine-tuned to a particular aspect ratio or even physical size, so the code will not reproduce exactly the same figure on a different-sized device.
These figures are raster equivalents or, in a couple of cases, raster conversions of the vector originals. The vector originals are of a much higher quality; these bitmaps are just to make it easier to identify a particular figure.
The code presented for each figure is self-contained, i.e., all code required to produce the figure is included. This means that there is sometimes considerable overlap of code between several figures (where the figures rely on common set-up code, e.g., the definition of variables, functions, or classes). This is particularly evident in the figures for Chapter 7. In some cases, it may be necessary to install an add-on package from CRAN to get the code to run.
Some of the figures from Chapters 2 and 3 (on traditional graphics) were actually produced using grid graphics code; it's just easier to do diagrams with grid sometimes.