Hello, I am having a bit of trouble with scatterplot3d(). I was able to plot a 3d cloud of points using the following code:>my.3dplot<-scatterplot3d(my.coords, pch=19, zlim=c(0,1), scale.y=0.5,angle=30, box=FALSE) where my.coords is a data frame that contains x, y, and z coordinates for grid points whose elevation we sampled. The problem occurs when I try to add points using points3d. I tried to follow the code in the examples of the package pdf. First, I tried the following code to add all of the points that I wanted:>my.3dplot$points3d(seq(400,600,0.19), seq(600,400,0.295),seq(800,500,0.24), seq(1000,1400,0.22), seq(1200,600,0.24), seq(1200,1500,0.28), seq(1300,1400,0.205), seq(1700,500,0.26), seq(1700,600,0.21), seq(1900,1400,0.255), seq(2300,1400,0.275), seq(2600,1300,0.225), seq(2700,400,0.235), seq(2700,1300,0.265), seq(3100,1000,0.135), col="blue", type="h", pch=16) and got the following error: Error in seq.default(600, 400, 0.295) : wrong sign in 'by' argument So I just tried to add the first point using the following code:>my.3dplot$points3d(seq(400,600,0.19), col="blue", type="h", pch=16)and got the following error message: Error in xyz.coords(x, y, z) : 'x', 'y' and 'z' lengths differ. Does anyone know how I can use this function in the scatterplot3d package? Thanks so much! Ryan ~~~~~~~~~~~~~~~~~~ Ryan D. Briscoe Runquist Population Biology Graduate Group University of California, Davis rdbriscoe at ucdavis.edu
On 8/13/2007 3:03 PM, Ryan Briscoe Runquist wrote:> Hello, > > I am having a bit of trouble with scatterplot3d(). > > I was able to plot a 3d cloud of points using the following code: > >>my.3dplot<-scatterplot3d(my.coords, pch=19, zlim=c(0,1), scale.y=0.5, > angle=30, box=FALSE) > > where my.coords is a data frame that contains x, y, and z coordinates for > grid points whose elevation we sampled. > > The problem occurs when I try to add points using points3d. I tried to > follow the code in the examples of the package pdf. > > First, I tried the following code to add all of the points that I wanted: > >>my.3dplot$points3d(seq(400,600,0.19), seq(600,400,0.295), > seq(800,500,0.24), seq(1000,1400,0.22), seq(1200,600,0.24), > seq(1200,1500,0.28), seq(1300,1400,0.205), seq(1700,500,0.26), > seq(1700,600,0.21), seq(1900,1400,0.255), seq(2300,1400,0.275), > seq(2600,1300,0.225), seq(2700,400,0.235), seq(2700,1300,0.265), > seq(3100,1000,0.135), col="blue", type="h", pch=16)The header to the function (which you can see by evaluating my.3dplot$points3d) is function (x, y = NULL, z = NULL, type = "p", ...) so you are setting x to seq(400,600,0.19), y to seq(600,400,0.295), etc. I think you probably want my.3dplot$points3d(x=c(400, 600, ...), y=c(600, 400, ...), z=c(0.19, 0.295, ...), ...) (where the ... is to be filled in by you.)> > and got the following error: > Error in seq.default(600, 400, 0.295) : wrong sign in 'by' argument > > So I just tried to add the first point using the following code: > >>my.3dplot$points3d(seq(400,600,0.19), col="blue", type="h", pch=16) > > and got the following error message: > > Error in xyz.coords(x, y, z) : 'x', 'y' and 'z' lengths differ. > > Does anyone know how I can use this function in the scatterplot3d package?try my.3dplot$points3d(x=400, y=600, z=0.19, col="blue", type="h", pch=16) Duncan Murdoch
Ryan Briscoe Runquist <rdbriscoe <at> ucdavis.edu> writes:> > > Hello, > > I am having a bit of trouble with scatterplot3d(). > > I was able to plot a 3d cloud of points using the following code: > > >my.3dplot<-scatterplot3d(my.coords, pch=19, zlim=c(0,1), scale.y=0.5, > angle=30, box=FALSE) > > where my.coords is a data frame that contains x, y, and z coordinates for > grid points whose elevation we sampled. > > The problem occurs when I try to add points using points3d. I tried to > follow the code in the examples of the package pdf. > > First, I tried the following code to add all of the points that I wanted: > > >my.3dplot$points3d(seq(400,600,0.19), seq(600,400,0.295), > seq(800,500,0.24), seq(1000,1400,0.22), seq(1200,600,0.24), > seq(1200,1500,0.28), seq(1300,1400,0.205), seq(1700,500,0.26), > seq(1700,600,0.21), seq(1900,1400,0.255), seq(2300,1400,0.275), > seq(2600,1300,0.225), seq(2700,400,0.235), seq(2700,1300,0.265), > seq(3100,1000,0.135), col="blue", type="h", pch=16)I think you probably want: xvals <- c(400,600,800,1000,1200,1200,1300,1700,1700,1900, 2300,2600,2700,2700,3100) yvals <- c(600,400,500,1400,600,1500,1400,500,600, 1400,1400,1300,400,1300,1000) zvals <- c(0.19,0.295,0.24,0.22,0.24,0.28,0.205,0.26, 0.21,0.255,0.275,0.225,0.235,0.265,0.135) my.3dplot$points3d(x=xvals,y=yvals,z=zvals,col="blue",type="h",pch=16) Look carefully at ?seq and you may understand what you've done wrong ... Ben Bolker