[R] help with scatterplot3d
murdoch at stats.uwo.ca
Mon Aug 13 21:31:42 CEST 2007
On 8/13/2007 3:03 PM, Ryan Briscoe Runquist wrote:
> 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:
> 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
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?
my.3dplot$points3d(x=400, y=600, z=0.19, col="blue", type="h", pch=16)
More information about the R-help