1

I was searching SO to find out how to draw matlab-like surface plots in R, and I found this page:

3d plot in R - Patch

I would like to use persp3d rather than persp, because of its interactive features, but persp by default has those lines of constant x and y on the surface (what would be called lines of longitude and latitude on a sphere) which I like, whereas I can't find any way to get the same using persp3d.

Is this feature available in persp3d?

Community
  • 1
  • 1
user3782261
  • 57
  • 1
  • 8

1 Answers1

4

You can call surface3d two times after you first call persp3d to add additional elements to the plot:

library(rgl)

x <- seq(-pi, pi, len = 20)
y <- seq(-pi, pi, len = 20)
z <- outer(x, y, function(x, y) sin(sqrt(x^2 + y^2))) 

persp3d(x, y, z, col = "blue")
surface3d(x, y, z, back = "lines")
surface3d(x, y, z, front = "lines")

3D Plot

JasonAizkalns
  • 20,243
  • 8
  • 57
  • 116
  • Using RStudio 1.0.153 on macOS, rotating the model with the mouse causes a lot of visual flickering on the surfaces. How can this be remedied? – forthrin Aug 18 '17 at 13:38