Search code examples
rrglplot3d

Increasing 3D surface plot thickness using the Plot3D package in R


Is there a way to increase a 3D surface plot thickness like the plots here using the persp3D() function in the plot3D package in R? Can't seem to find anything in the documentation.


Solution

  • I was able to get this to work by creating multiple surfaces and connecting them using the curtain argument of the plot3D function. The thickness was controlled by the z argument of each surface. In case anyone needs the sample code, here it is;

    For simplicity, I used meters to specify thicknesses/height of the surfaces

    library(plot3D)
    library(plot3Drgl)
    
    # volcano data range
    clim <- range(volcano)
    
    # Surface 1
    persp3D(z = volcano, zlim = c(0, 600), clim = clim, 
            box = FALSE, plot = FALSE, curtain = TRUE, border = "black")
    
    # Surface 2 - 20m below surface 1
    persp3D(z = volcano - 20, clim = clim, colvar = volcano, 
            add = TRUE, colkey = FALSE, plot = FALSE, curtain = TRUE, border = "black")
    
    # Surface 3 - 40m below surface 1
    persp3D(z = volcano - 40, clim = clim, colvar = volcano, 
            add = TRUE, colkey = FALSE, plot = FALSE, curtain = TRUE, border = "black")
    
    # Surface 4 - 60m below surface 1
    persp3D(z = volcano - 60, clim = clim, colvar = volcano, 
            add = TRUE, colkey = FALSE, plot = TRUE, curtain = TRUE, border = "black")
    
    # Surface 5 - 80m below surface 1
    persp3D(z = volcano - 80, clim = clim, colvar = volcano, 
            add = TRUE, colkey = FALSE, plot = TRUE, curtain = FALSE, border = "black")
    
    # Open rgl for interactive viewing
    plotrgl()
    

    enter image description here