Graph Examples from Visualizing Data by William Cleveland

[This article was first published on Software for Exploratory Data Analysis and Statistical Modelling, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 their blog: Software for Exploratory Data Analysis and Statistical Modelling.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)