R 如何绘制覆盖立方体

R 如何绘制覆盖立方体,r,3d,R,3d,如何绘制覆盖的多维数据集?比如说, #cube 1 x1 <- c(0,1,1,0,0, 1,1,1,1,1, 1,1,0,0,1, 0,0,0,0,0, 0,1,1,0,0, 0,1,1,0,0) y1 <- c(1,1,1,1,1, 1,0,0,1,1, 0,0,0,0,0, 0,0,1,1,0, 1,1,0,0,1, 1,1,0,0,1) z1 <- c(0,0,1,1,0, 0,0,1,1,0, 0,1,1,0,0, 0,1,1,0,0, 0,0

如何绘制覆盖的多维数据集?比如说,

#cube 1
x1 <- c(0,1,1,0,0,  1,1,1,1,1,  1,1,0,0,1,  0,0,0,0,0, 0,1,1,0,0,  0,1,1,0,0) 
y1 <- c(1,1,1,1,1,  1,0,0,1,1,  0,0,0,0,0,  0,0,1,1,0, 1,1,0,0,1,  1,1,0,0,1)
z1 <- c(0,0,1,1,0,  0,0,1,1,0,  0,1,1,0,0,  0,1,1,0,0, 0,0,0,0,0,  1,1,1,1,1)


#cube 2
x2 <- .5*c(0,1,1,0,0,  1,1,1,1,1,  1,1,0,0,1,  0,0,0,0,0, 0,1,1,0,0,  0,1,1,0,0) 
y2 <- .5*c(1,1,1,1,1,  1,0,0,1,1,  0,0,0,0,0,  0,0,1,1,0, 1,1,0,0,1,  1,1,0,0,1)
z2 <- .5*c(0,0,1,1,0,  0,0,1,1,0,  0,1,1,0,0,  0,1,1,0,0, 0,0,0,0,0,  1,1,1,1,1)

#cube 3
x3 <- .3*c(0,1,1,0,0,  1,1,1,1,1,  1,1,0,0,1,  0,0,0,0,0, 0,1,1,0,0,  0,1,1,0,0) 
y3 <- .3*c(1,1,1,1,1,  1,0,0,1,1,  0,0,0,0,0,  0,0,1,1,0, 1,1,0,0,1,  1,1,0,0,1)
z3 <- .3*c(0,0,1,1,0,  0,0,1,1,0,  0,1,1,0,0,  0,1,1,0,0, 0,0,0,0,0,  1,1,1,1,1)
#立方体1

x1您可以使用
rgl
中的
plot3d
执行此操作:

library(rgl)
#first cube
plot3d(x1, y1, z1, type="p", col="red", xlab="x", 
       ylab="y", zlab="z", site=5, lwd=15)
#second cube (notice add=TRUE to overlay)
plot3d(x2, y2, z2, type="p", col="blue", xlab="x", 
       ylab="y", zlab="z", site=5, lwd=15, add=TRUE)
#third cube (notice add=TRUE to overlay)
plot3d(x3, y3, z3, type="p", col="green", xlab="x", 
       ylab="y", zlab="z", site=5, lwd=15, add=TRUE)
输出:


您可以使用
rgl
中的
plot3d
执行此操作:

library(rgl)
#first cube
plot3d(x1, y1, z1, type="p", col="red", xlab="x", 
       ylab="y", zlab="z", site=5, lwd=15)
#second cube (notice add=TRUE to overlay)
plot3d(x2, y2, z2, type="p", col="blue", xlab="x", 
       ylab="y", zlab="z", site=5, lwd=15, add=TRUE)
#third cube (notice add=TRUE to overlay)
plot3d(x3, y3, z3, type="p", col="green", xlab="x", 
       ylab="y", zlab="z", site=5, lwd=15, add=TRUE)
输出:


我编辑了这些点。你的答案很完美。你能编辑你的身材吗?那么,答案就完整了。谢谢。我编辑了该图并添加了一些注释,以便向其他有相同问题的用户澄清。可以显示立方体,修改
type=“p”
type=“l”
。我编辑了这些点。你的答案很完美。你能编辑你的身材吗?那么,答案就完整了。谢谢。我编辑了该图并添加了一些注释,以便向其他有相同问题的用户澄清。可以显示立方体,修改
type=“p”
type=“l”
参数。