Chapter 7

The grid Graphics Object Model

Chapter preview

This chapter describes how to work with graphical objects (grobs). The main advantage of this approach is that it is possible to modify a scene that was produced using grid without having to modify the source code that produced the scene. Because lattice and ggplot2 are built on grid, this means it is possible to modify a ggplot2 or lattice plot.

There are also benefits from being able to do such things as ask a piece of graphical output how big it is. For example, this makes it easy to leave space for a legend beside a plot.

Graphical objects can be combined to form larger, hierarchical graphical objects (gTrees). This makes it possible to control the appearance and position of whole ...

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.