3d scatter plot using R

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)

RESULT
3dscatterplot.jpeg

DATA
Data: Copy and paste in a file and save it as 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

Comments

Re: 3d scatter plot using R

Dear Sir...Sometimes we wonder where you get so much of passion for Statistics from!!! :)

Re: 3d scatter plot using R

That's a great complement, Aniqa!
There are tons of more things to know.. life is way too short to know all of them. I try to know new things and share with others. I find joy in doing so.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • LaTex commands embedded in text will be interpreted and rendered. Additional information can be found at DruTex Documentation Pages
    • Assists automatic numbering of tex, equation, and equations environments.
    • Provides different environments to create rendered images (especially maths).
    • You may use <swf file="song.mp3"> to display Flash files inline
    • You can use BBCode tags in the text.

    More information about formatting options

Google Video

Loading...
Loading...