使用rect3Drgl()
时我有一种奇怪的行为。这是我的剧本:
library(rgl)
library(plot3Drgl)
uvw = matrix(c(1,-1,0, 0,0,1, 0,1,-1), ncol=3)
plot3d(uvw, xlab="", ylab="", zlab="", xlim=c(-2,2), ylim=c(-2,2), zlim=c(-2,2))
segments3d(c(-2-0.2,2-0.2), c(0,0), c(0,0), col="black", lwd=3)
segments3d(c(0,0), c(-2-0.2,2-0.2), c(0,0), col="black", lwd=3)
segments3d(c(0,0), c(0,0), c(-2-0.2,2-0.2), col="black", lwd=3)
text3d(matrix(c(2,0,0, 0,2,0, 0,0,2),ncol=3),texts=c('x+', 'y+', 'z+'))
# semi-transparent planes on xy, xz, and yz planes
rect3Drgl(x0 = 0, y0 = -2, z0 = -2, x1 = NULL, y1 = 2, z1 = 2,
lwd=1, col="#0000ff", alpha=0.1, add=TRUE) #yz
rect3Drgl(x0 = -2, y0 = 0, z0 = -2, x1 = 2, y1 = NULL, z1 = 2,
lwd=1, col="#ff0000", alpha=0.1, add=TRUE) #xz
rect3Drgl(x0 = -2, y0 = -2, z0 = 0, x1 = 2, y1 = 2, z1 = NULL,
lwd=1, col="#00ff00", alpha=0.1, add=TRUE) #xy
如果我按原样运行脚本,每次调用rect3Drgl()
时都会收到此错误:
cbind错误(as.vector(x),as.vector(y),as.vector(z),1)%*%plist $ mat: 需要数字/复杂矩阵/向量参数
但是,如果我先运行它,然后关闭新的图形窗口......
rect3Drgl(x0 = -2, y0 = -2, z0 = 0, x1 = 2, y1 = 2, z1 = NULL,
lwd=1, col="#00ff00", alpha=0.1) # remove add=TRUE
现在我可以运行这三个rect3Drgl(...)
语句并得到我可爱的情节:
为什么我必须在没有add = TRUE的情况下运行rect3Drgl()
以使我的情节与add = TRUE一起使用?