[R] help with scatterplot3d

Ben Bolker bolker at ufl.edu
Mon Aug 13 23:17:05 CEST 2007

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,
yvals <- c(600,400,500,1400,600,1500,1400,500,600,
zvals <- c(0.19,0.295,0.24,0.22,0.24,0.28,0.205,0.26,

   Look carefully at ?seq and you may understand what you've
done wrong ...

  Ben Bolker

More information about the R-help mailing list