1
votes

I am trying to add a overall title to a 3d plot with multiple subplots using the rgl package from R,and i am also trying to set the distance between two sub scenes. In 2D plot, we can use title("my title",outer=TRUE) to gave an overall title, and "mar" to set the margin. So, what is the corresponding parameters? Here are my code:

 rgl.viewpoint(0,0,fov=0)
 par3d(windowRect=c(50,50,700,700),zoom=0.8)
 mat<-matrix(c(1,2,3,4,5,6),3,2,byrow = TRUE)
 height<-c(2,2,2)
 width<-c(1,1)
 layout3d(mat, height = height,width=width,sharedMouse = TRUE)
 for (i in 1:6) {
    next3d()
    shade3d(shapes[[i]], col = col[i])
 }

I want to put a title in the picture and adjust the distance between two subplots.

1
Please ckeck your code since I am getting Error in shade3d(shapes[[i]], col = col[i]) : object 'shapes' not found - Crparedes
shapes <- list(Tetrahedron = tetrahedron3d(), Cube = cube3d(), Octahedron = octahedron3d(), Icosahedron = icosahedron3d(), Dodecahedron = dodecahedron3d(), Cuboctahedron = cuboctahedron3d()) col <- rainbow(6) - haidan li

1 Answers

1
votes

There's no concept of outer regions in rgl. What you need to do is to add another region to your layout, and put the title there. For example,

library(rgl)
open3d()
mat<-matrix(c(7,7,1,2,3,4,5,6),4,2,byrow = TRUE)
height<-c(1,2,2,2)
width<-c(1,1)
layout3d(mat, heights = height, widths=width, sharedMouse = TRUE)
for (i in 1:6) {
        next3d()
        shade3d(cube3d(), col = i)
}
next3d()
text3d(0,0,0,"My title")