points3Drgl 不显示

points3Drgl not displaying

我在将一些绘图从 plot3D 转换为 plot3Drgl 时遇到问题。

这会产生没有问题的情节

require(plot3D)
persp3D(z=matrix(runif(100),nrow=10, ncol=10), clab = "m", shade = 0.2,  
col="#DDDDDD", colkey = FALSE, theta=20, phi=30,  plot=FALSE, zlim = c(0,2))
points3D(x=0.5,y=0.5,z=1.5, col="#FF0000", add=TRUE, plot=TRUE, pch = 20, cex = 2 )

使用 plot3Drgl 的相同方法会引发错误:

require("plot3Drgl")
persp3Drgl(z=matrix(runif(100),nrow=10, ncol=10), clab = "m", shade = 0.2,  
col="#DDDDDD", colkey = FALSE, theta=20, phi=30,  plot=FALSE, zlim = c(0,2))
points3Drgl(x=0.5,y=0.5,z=1.5, col="#FF0000", add=TRUE, plot=TRUE, pch = 20, cex = 2 )

我得到的错误是:

Error in if (dots$add) rgldots$new <- FALSE : argument is of length zero

我想在这里实现的是将单点添加到 3D 表面。

提前致谢

兆焦耳

我不是 plot3D 专家,但是按照帮助 ?points3Drgl 应该会给你一个答案:

The first step in 3D rgl plotting consists in calling the corresponding 3-D function from package plot3D with argument plot set to FALSE.

The next step is to create a 3-D rgl plot, by calling plotrgl.

所以调用您的正常 plot3D 函数,使用 plot = F 然后简单地 plotrgl()

library(plot3D)
library(plot3Drgl)
persp3D(z=matrix(runif(100),nrow=10, ncol=10), clab = "m", shade = 0.2,  
col="#DDDDDD", colkey = FALSE, theta=20, phi=30,  plot=FALSE, zlim = c(0,2))
points3D(x=0.5,y=0.5,z=1.5, col="#FF0000", add=TRUE, plot=FALSE, pch = 20, cex = 2 )
plotrgl()