Friday, October 2, 2009

3d scatterplot using R


3dscatterplot.jpeg3dscatterplot.jpegThe other day I saw a three dimensional scatterplot in Montgomery's Regression book. I wanted to redraw the graph using the provided data. A simple google search revealed that there is a package calledscatterplot3d. The scatterplot3d() can be used to draw a 3-dimensional scatter plot. Here is what the steps are:

Download and install the package from your nearest CRAN.
Load the package using the command library(scatterplot3d)

Us the attached file to run the following code in R.

 d1<-read.table("65-555-reg.txt", header=T) d2<-data.frame(time=c(d1[,1]), cases=c(d1[,2]), distance=c(d1[,3])) attach(d2) require(scatterplot3d) windows(6,5) scatterplot3d(cases, distance, time, angle=20, col.axis="blue", col.grid="lightblue", main="Three-dimensional scatterplot",  pch=21, box=F, cex.symbols=2) detach(d2) 

External sources:
The original PDF file containing all the functions in the scatterplot3d package.
Author's (Uwe Ligges) Webpage

Attachment Size
65-555-reg.txt 329 bytes

No comments:

Post a Comment