Base Graphics
Base graphics is the oldest and original graphic system built for R. This is the core plotting system and contains functions including plot()
, hist()
, boxplot()
and many others. The code for base graphics is in the graphics package, which is loaded by default when you start R.
Grid
Grid is an alternative graphic system which was added to R at a later stage. It implements a completely different graphic system independent of the core graphics package. It is more like a framework and doesn't produce complete graphics by itself. For this reason, we seldom call functions from the grid package directly.
Lattice
Lattice is an add-on graphic package that contains code for producing Trellis graphics - graphs that display a variable or the relationship between variables, conditioned on one or more other variables. It includes functions like xyplot()
, bwplot()
, levelplot()
, histogram()
. Lattice graphics in R make use of grid graphics. This is incompatible with Base graphics package.
ggplot2
ggplot2 is a system for 'declaratively' creating graphics, based on "The Grammar of Graphics". You provide the data, tell 'ggplot2' how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details. Here is the statement of purpose for the ggplo2 package - ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and none of the bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered graphics.
Base graphics are used most commonly and are a very powerful system for creating 2-D graphics. In this course, we will focus on the Base graphics system and ggplot2.