如何在 R 中创建 4D 轮廓曲面图?

时间:2021-05-23 21:27:00

标签: r plot contour surface 4d

我有包含三个输入变量和一个输出变量的 4D 数据。现在我想在 R 中绘制一个 4D 轮廓曲面图,该图的三个轴等于三个输入变量,轮廓曲面显示输出。如图。任何人都可以帮助创建它吗?

4D plot

我的代码是:

Dt<-seq(0,150, length=20)
Vt<-seq(0, 1400, length=20)
Pt<-seq(0,400, length=20)

rr <- expand.grid(Dt=Dt, Vt=Vt, Pt=Pt)

library(FAdist)

Fp2<-NULL
Fd2<-NULL
Fv2<-NULL

Fp2<-pgamma(rr$Pt, shape=0.9, scale =83.5)
Fd2<-pgamma3(rr$Dt, shape=0.39, scale=53.3, thres=0)
Fv2<-pweibull(rr$Vt, shape=0.54, scale=41.5)

library(VineCopula)

z_12<-BiCopCDF(Fp2, Fd2, family = 5, par = 5.74, par2 = 0, obj = NULL, check.pars = TRUE)
z_23<-BiCopCDF(Fd2, Fv2, family = 5, par = 12.8, par2 = 0, obj = NULL, check.pars = TRUE)
z_13<-BiCopCDF(Fp2, Fv2, family = 5, par = 7.73, par2 = 0, obj = NULL, check.pars = TRUE)

Z_123<-BiCopCDF(z_12,z_23, family = 5, par = -2.47, par2 = 0, obj = NULL, check.pars = TRUE)
p<-(1-Fp2-Fd2-Fv2+z_12+z_23+z_13-Z_123)
E_L<-0.2894
T_123<-(E_L)/(p)

rr$zt<-T_123

现在我想创建一个 4D 图(用于 rr 数据),其中包含三个输入轴,包括 Pt、Dt、Vt 和轮廓表面中的输出 Zt。

我也试过 misc3d::contour3drgl::plot3d,它有一些缺点,包括当数据为正时,我得到错误:subscript out of bounds。此外,输出没有曲面值的 colkey 指南。

library(misc3d)
library(rgl)

levels <- (1:19)/20
colors <-  rainbow(19)
zt <- array(rr$zt, c(length(Pt), length(Vt), length(Dt)))

plot3d(rr, type = "n")
contour3d(zt, levels, Pt, Vt, Dt, color = colors, add = TRUE)

错误:

#Error in tris[3 * (1:n) - 2, ] : subscript out of bounds

有没有人有更好的解决方案来显示更好的输出,就像我上面放的图一样?

0 个答案:

没有答案