我创建了一个表面3D图。
library(emdbook)
params <- c(a0=0.387217066,a1=0.328086337,a2=0.004177033,
p0=1.117997,p1=5.426564,p2=-220.745499)
Age<- as.matrix(seq(0:299))
Preci<-as.matrix(seq(from=10, to=3000, by=10))
curve3d(with(as.list(params),
a0*(Age^a1)*exp(-a2*Age)*
p0*(1-exp(-exp(-p1)*(Preci-p2)))),
varnames=c("Age","Preci"),
xlim=c(0,300),ylim=c(10,3000),
sys3d="persp", col='gray',
xlab = "Stand Age", ylab = "Annual precipitation", zlab = "GPP",
phi = 25, theta = 40)
然而,色标是灰色的,我想让它与我的z值(GPP)相关。谁知道怎么做?
答案 0 :(得分:0)
library(emdbook)
jet.colors <- # function from grDevices package
colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan",
"#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"))
colorzjet <- jet.colors(300)
params <- c(a0=411.796734040,a1=0.363361894,a2=-0.005016735,
p0=-3.418487e+05,p1=-3.883484e-06)
Age<- as.matrix(seq(0:299))
Preci<-as.matrix(seq(from=10, to=3000, by=10))
curve3d(with(as.list(params),
a0*(Age^a1)*(exp(-a2*Age))*
((p0*(1-exp(-p1*Preci))))),
varnames=c("Age","Preci"),
xlim=c(0,300),ylim=c(10,3000),
sys3d="persp", col=colorzjet[ findInterval(z, seq(min(z), max(z), length=300))],
xlab = "Stand Age", ylab = "Annual precipitation", zlab = "GPP",
phi = 25, theta = 40)