Graph Examples from Visualizing Data by William Cleveland

November 12th, 2009

The trellis graphics approach was pioneered by various statistical researchers and the ideas are used extensively in the book “Visualizing Data” by William Cleveland. There are various resources on the website for trellis graphics including S code for creating the majority of the graphs that appear in the book. Inspired by efforts on the Learning R blog to recreate the examples from Deepayan Sarkar’s book on lattice using ggplot2 I have decide to undertake a similar exercise based on the scripts that have been made available for creating the graphs from the book.

The script has code for six figures from the first chapter and my efforts to recreate these graphs produced the following results.

Figure 1.1

Figure 1.2

The code for this example was:

qplot(height, data = singer, xlab = "Height (inches)") +
  geom_histogram() + facet_wrap( ~ voice.part, ncol = 2)

This was straightforward to recreate and the main difference is that the Trellis display has an aspect to make the panels square.

Histogram of height by singing part

Histogram of height by singing part

Figure 1.3

Figure 1.4

The code for this example was:

qplot(E, NOx, data = ethanol, xlab = "E",
  ylab= "Oxides of Nitrogen\n(micrograms/J)")

This graph was easy to recreate.

Scatterplot of NOx against Ethanol

Scatterplot of NOx against Ethanol

Figure 1.5

The code for this example was:

qplot(C, NOx, data = ethanol, xlab = "C",
  ylab= "Oxides of Nitrogen\n(micrograms/J)")

This graph was easy to recreate.

Scatterplot of NOx against Carbon

Scatterplot of NOx against Carbon

Figure 1.6

The code for this example was:

qplot(yield, variety, data = barley, xlab = "Barley Yield (bushels/acre)") +
  geom_point() + facet_grid(site ~ year)

As with the previous example with conditioning the panels are stretched to fit the plot region which differs from the Trellis graphic that is created.

Dot plot of barley yields conditioning by year and location

Dot plot of barley yields conditioning by year and location

Comments are closed.