title: Add grid over 3D surface using persp3D (plot3D package)
body: <p>I'm trying to add a grid on top of a 3D surface created with <code>persp3D</code> (package <code>plot3D</code>), however I can't sort a way of doing it without causing a deformation on the grid.</p>
  <pre><code>library(plot3D)
  data(&quot;volcano&quot;)
  </code></pre>
  <p><code>volcano</code> is a 3D matrix that can be used to create a 3D plot by simply calling:</p>
  <pre><code>persp3D(z=volcano)
  </code></pre>
  <p>What I intend to do is create a new grid using the dimensions of the 3D matrix and than add it to the 3D plot.</p>
  <pre><code># new grid
  x.seq &lt;- seq(1, dim(volcano)[1], length = 20)
  y.seq &lt;- seq(1, dim(volcano)[2], length = 20)
  
  # Visualize grid
  plot(x=c(0,length(volcano[,1])), y=c(0,length(volcano[1,])), type='n')
  abline(v=x.seq, h=y.seq)
  </code></pre>
  <p>I got close to it by subsetting the matrix <code>volcano</code> by the new sequences created and then plot the new 3D matrix over the original 3D surface.</p>
  <pre><code># New matrix using sequences created
  mtx.sub &lt;- volcano[time.seq, freq.seq]
  
  # Plot new matrix on top of original surface
  persp3D(z=volcano)
  persp3D(z=amp.sub, border=&quot;black&quot;, facets=NA, add=T, colkey=list(plot=F))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/XI9h1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XI9h1.jpg" alt="3D plot with overlaid grid" /></a></p>
  <p>Even though the result is close to what I expected, a closer look will show that the grid is not really on top of the existing surface, it is a whole new surface that do not match the original one (which is quite obvious, given that it is a different matrix).</p>
  <p>What I'm looking for is a way to add a 2D grid that will go over the original surface, something similar to <code>abline</code>, but for a 3D plot.</p>
  <p>I had a look at <code>plot3D</code> documentation and searched on the web, but none of the solutions apply to <code>persp3D()</code>.</p>
  <p>Any thoughts on a way around this?</p>