简体   繁体   English

在R中绘制曲面3D图的问题

[英]Issue with plotting a surface 3D plot in R

I am trying to do a 3D surface plot as follow: 我正在尝试绘制3D表面图,如下所示:

library (emdbook)

params <- c(a0=0.165451439, a1=-0.003771699, a2=-1.319022091, a3= -0.148502307,
            p0=4.752635e-11,p1=-2.625385e-07, p2=4.166868e-04, p3=-1.049669e-01)
Age<- as.matrix(seq(0:299)) 
Preci<-as.matrix(seq(from=10, to=3000, by=10))
curve3d(with(as.list(params),
             a0*(exp(a1*Age)) +a2*(exp(a3*Age))*
               ((p0*Preci^3+p1*Preci^2 + p2*Preci + p3))),
        varnames=c("Age","Preci"), xlim=c(0,100), ylim=c(100,3000),
        sys3d="rgl")

However, the output gives me a weird shape at the beginning of the curve. 但是,输出在曲线的开头给了我一个怪异的形状。 Does anyone know what I am doing wrong? 有人知道我在做什么错吗? Is it the interaction between the two functions (age and Preci) that I am doing wrong? 我做错的是两个功能(年龄和精确度)之间的相互作用吗?

I figured that to make interactions between function, one needs to use the + sign instead of the * sign. 我认为要在函数之间进行交互,需要使用+号而不是*号。 Therefore the command line becomes : 因此,命令行变为:

library (emdbook)

params <- c(a0=0.165451439, a1=-0.003771699, a2=-1.319022091, a3= -0.148502307,
            p0=4.752635e-11,p1=-2.625385e-07, p2=4.166868e-04, p3=-1.049669e-01)
Age<- as.matrix(seq(0:299)) 
Preci<-as.matrix(seq(from=10, to=3000, by=10))
curve3d(with(as.list(params),
             a0*(exp(a1*Age)) +a2*(exp(a3*Age))+
               ((p0*Preci^3+p1*Preci^2 + p2*Preci + p3))),
        varnames=c("Age","Preci"), xlim=c(0,100), ylim=c(100,3000),
        sys3d="rgl")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM