I want to produce a 3D surface in R where y is flux, x
is Age and z
is precipitation. I have a range of age between 0 and 152 and a range of precipitation 0 and 2600.
I also have two functions where flux is function of Age or Precipitation:
Flux= 0.387217066*(Age^0.328086337)*(exp(-0.004177033*Age)
and
Flux= 1.117997*(1-exp(-exp(-5.426564)*(Preci-(-220.745499))
What I want to achieve is something a bit like this:
I have tried to do it with the package plot3D
in R without success (see below)
Age<- as.matrix(seq(0:152))
Preci<-as.matrix(seq(from=10, to=2600, by=17))
Flux= as.matrix(0.387217066*(Age^0.328086337)*(exp(-0.004177033*Age)) - 1.117997*(1-exp(-exp(-5.426564)*(Preci-(-220.745499)))))
surf3D(Age, Preci, Flux, colvar = Flux, colkey = FALSE, facets = FALSE)
I got this error message
Error in if (is.na(var)) ispresent <- FALSE else if (length(var) == 1) if (is.logical(var)) if (!var) ispresent <- FALSE :
argument is of length zero