I am trying to use the package plot3D
to plot my xyz data with the color based on 4th variable.
My data looks like this:
data.frame(xx,yy,zz,Ammpl)
xx yy zz Ammpl
1 63021.71 403105.0 1.181028516 1170
2 63021.71 403105.0 0.977028516 1381
3 63021.71 403105.0 0.861028516 807
4 63021.71 403105.0 0.784028516 668
5 63021.71 403105.0 0.620028516 19919
6 63021.71 403105.0 0.455028516 32500
7 63021.71 403105.0 0.446028516 32500
8 63021.71 403105.0 0.436028516 32500
9 63021.71 403105.0 0.426028516 32500
10 63021.71 403105.0 0.281028516 17464
First thing I did was use from the package akima
the function interp
. To create a regular grid
s100<-interp(xx,yy,zz, xo=seq(min(xx):max(xx), length=30, yo=seq(min(yy):max(yy), length=30), duplicate="mean")
From the package plot3D
in used the function slice3D
slice3D(x = s100$x, y = s100$y, z = s100$z, colvar = ampl,
ys = 1:10, zs = NULL, NAcol = "black",
expand = 0.4, theta = 45, phi = 45)
My problem is I don't know how to build data ampl
for colvar
so it will provide the colouring in this plot.
I have tried a lot of things but I thinks this is where I get stuck.
In example(slice3D)
they use oxsat$val
from data(oxsat)
to create the colvar
.
> dim(Oxsat$val)
[1] 180 90 33