3 Data Visualization

In the next few sections, we will produce several varieties of scatter plots, box-and-whisker plots (from here on after ‘boxplots’), histograms and density plots, and plots with error bars. All of these will first be produced using the lattice package and then an attempt is made to recreate these in (pretty much) the exact same way in ggplot2. First, the default versions are created and then we will see how they can be modified in order to produce plots that satisfy the requirements of most academic journals.

We will see that some things are easier to achieve using lattice, whereas other things are easier in ggplot2, so it is probably good advice to learn how to use both of them…