Base, Grid, and Lattice Graphics in R

By Andrie de Vries, Joris Meys

Perhaps confusingly, the standard distribution of R actually contains three different graphics packages. Once understood, these tools will greatly enhance the impact of your work in R.

  • Base graphics is the graphics system that was originally developed for R. The workhorse function of base graphics is a plot(). The code for base graphics is in the graphics package, which is loaded by default when you start R.

  • Grid graphics is an alternative graphics system that was later added to R. The big difference between grid and the original base graphics system is that grid allows for the creation of multiple regions, called viewports, on a single graphics page.

    Grid is a framework of code and doesn’t, by itself, create complete charts. The author of grid, Paul Murrell, describes some of the ideas behind grid graphics on his website.

    The grid package needs to be loaded before you can use it.

  • Lattice is a graphics system that specifically implements the idea of Trellis graphics (or faceted graphics), which was originally developed for the languages S and S-Plus at Bell Labs. Lattice graphics in R make use of grid graphics.

    This means that the functions for creating graphics and changing options in base and lattice are mostly incompatible with one another.

    The lattice package needs to be loaded before use.