I have a big dataset with x
, y
, and z
and two other variables. I want to plot them in a way that I can make 3D slides out of the data with a 4th (and later also with a 5th) variable as a color index.
I am trying to use slice3D()
from package plot3D
but my data is not in the correct form and I can't figure out how to organise the data. The code I want to use:
library(plot3D)
slice3D(x = x, z = z_NAP, y = y, colvar = ampl,
ys = 1:10, zs = NULL, NAcol = "black",
expand = 0.4, theta = 45, phi = 45)
The data looks like this:
x=c(53024.14,53024.14,63024.14,53024.14,53024.14,53023.98,53023.98,53023.98,53023.98, 53023.98,63023.98)
y=c(403100.1,403100.1,403100.1,403100.1,403100.1,403100.2,403100.2,403100.2,403100.2,403100.2,403100.2)
z_NAP=c(-2.2695537,-2.5505537,-2.7335537,-2.9175537,-3.2265537,1.1271519,0.9331519,0.6431519,0.4791519,0.2951519,0.0251519)
ampl=c(7196,195,5103,4537,6763,1207,2059,14121,26126,11850,9883)
I sorted the xyz data with interp
because I have the same values for the x
and y
while z
is changing.
s100<-interp(x, y, z, xo=seq(min(x), max(x), length=30),
yo=seq(min(y), max(y), length=30), duplicate="mean")
I have a matrix of x
y
with z
values in it. But now I need to make matrix containing xyz
and the other variable.
I've got this matrix:
dim(s100$z)
30 30
And I need ampl
to be 30 x 30 x 30.