Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Box and Whisker Plot

A simple box plot of randomly generated data. The box in each plot shows the median (as the line within the box) and one standard deviation from the mean (the extremes of the box). The whiskers show the second standard deviation, and the circles show outliers.

In this code we use R's rnorm function to generate a standard_normal random matrix of the given shape (rows by cols). The dataset is transformed to an R data frame. The x axis is labelled with an appropriate number of letters from the alphabet.




set.seed(2)
ds <- matrix(rnorm(19 * 100), ncol = 19)
pdf("graphics/rplot-boxplot.pdf")
  plot.new()
  plot.window(xlim = c(0, 20), ylim = range(ds), xaxs = "i")
  boxplot(as.data.frame(ds), add = TRUE, at = 1:19)
dev.off()

http://rattle.togaware.com/code/rplot-boxplot.R



Copyright © Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
The PDF version is a formatted comprehensive draft book (with over 800 pages).
Brought to you by Togaware. This page generated: Saturday, 16 January 2010