title: 3D density plot with multiple groups ( regression lines)
body: <p>I would like to create plot something like this :</p>
  
  <p><a href="https://i.stack.imgur.com/zCM84.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zCM84.png" alt="Nether et al"></a></p>
  
  <p>Here we have two variables X = midyear and Y = yearend. I would like to create density plot for each level of X for Y. </p>
  
  <p>I could go to this point, but do not look pretty like what I have in mind particularly angle of the plot and line. Any idea to make such twist or other packages that can do.  </p>
  
  <pre><code>set.seed(1234)
  m50 &lt;- rnorm(10000, 51, 5)
  d50 &lt;- hist(m50, breaks = 100)$density
  md50 &lt;- hist(m50, breaks = 100)$mids
  
  m70 &lt;- rnorm(10000, 73, 5)
  d70 &lt;- hist(m70, breaks = 100)$density 
  md70 &lt;- hist(m70, breaks = 100)$mids
  
  m90 &lt;- rnorm(10000, 90,5)
  d90 &lt;- hist(m90, breaks = 100)$density 
  md90 &lt;- hist(m90, breaks = 100)$mids
  
  density = c(d50, d70, d90)
  yearend = c(md50, md70, md90)
  midyear = c(rep(50, length(d50)), rep(70, length(d70)), rep(90, length(d90)))
  
  df &lt;- cbind(midyear, yearend,  density)
  require(scatterplot3d)
  s3d &lt;- scatterplot3d(df, type = "h", color = "blue",
         angle = 80, scale.y = 0.7, xlim = c(40, 100), 
     zlim = c(0,0.2), pch = ".", main = "Adding elements")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IhBKQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IhBKQ.png" alt="enter image description here"></a></p>
  
  <p><strong>Edits:</strong>
  Using rgl package</p>
  
  <pre><code>require(rgl)
  s3d &lt;- plot3d(df, type = "h", 
                       angle = 80, scale.y = 0.7, xlim = c(40, 100), 
                       zlim = c(0,0.15), pch = ".", main = "Adding elements")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/vdv2N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vdv2N.png" alt="enter image description here"></a></p>