Graph Examples from Visualizing Data by William Cleveland

November 12, 2009
By

(This article was first published on Software for Exploratory Data Analysis and Statistical Modelling, and kindly contributed to R-bloggers)

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 Nitrogenn(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 Nitrogenn(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

To leave a comment for the author, please follow the link and comment on his blog: Software for Exploratory Data Analysis and Statistical Modelling.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , ,

Comments are closed.