The 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 called scatterplot3d. 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)

Use 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)
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)




Data file (save the data in a file. I called it 65-555-reg.txt)

time cases distance
16.68 7 560
11.5 3 220
12.03 3 340
14.88 4 80
13.75 6 150
18.11 7 330
8 2 110
17.83 7 210
79.24 30 1460
21.5 5 605
40.33 16 688
21 10 215
13.5 4 255
19.75 6 462
24 9 448
29 10 776
15.35 6 200
19 7 132
9.5 3 36
35.1 17 770
17.9 10 140
52.32 26 810
18.75 9 450
19.83 8 635
10.75 4 150

External sources:
The original PDF document.
Author's (Uwe Ligges) Webpage

 

0 comments