使用plot3d在单个绘图窗口中绘制多个3D图像

时间:2014-08-15 03:51:23

标签: r plot rgl

当我使用plot3d包中的rgl绘制多个3D图像时,图像会单独显示。我想在一个图中显示它们,例如,当使用par(mfrow=c(2, 2))在单个绘图窗口中显示四个2D图像时。

这可能吗?

1 个答案:

答案 0 :(得分:4)

命令 layout3d 可能很有用。也许这段代码可以提供帮助:

 shapes <- list(Tetrahedron = tetrahedron3d(), Cube = cube3d(), Octahedron =  octahedron3d(),
 Icosahedron = icosahedron3d(), Dodecahedron = dodecahedron3d(),
 Cuboctahedron = cuboctahedron3d())
 col <- rainbow(6)
 open3d()

 mat <- matrix(1:4, 2, 2)
 mat <- rbind(mat, mat + 4, mat + 8)
 layout3d(mat, height = rep(c(3, 1), 3), sharedMouse = TRUE)
 for (i in 1:6) {
 next3d()
 plot3d(shapes[[i]], col = col[i])
 next3d()
 text3d(0, 0, 0, names(shapes)[i])
 }

要停用所有实体的旋转,只需放置 sharedMouse = FALSE 即可。