We have already seen that
qplot()is a simple function that can be used to generate plots quickly, but for more detailed control of the plot layers, the
ggplot2 package also provides a more sophisticated function,
ggplot(). Using this function, we first create a plot object in which we define the data and the aesthetic mapping we are interested in representing, and afterwards, we add elements such as
geom and stat that produce the actual plot. Just remember that aesthetic mapping not only includes the colors and sizes of plotting elements, but also the x-y mapping to the axis. In the previous chapter, we showed an example of creating a scatterplot with the
ToothGrowth dataset, where it described ...