title: R - Plotting two bivariate normals in 3d and their contours respectively
body: <p>I have been playing around with the MASS package and can plot the two bivariate normal simply using image and par(new=TRUE) for example:</p>
  
  <pre><code># lets first simulate a bivariate normal sample
  library(MASS)
  bivn &lt;- mvrnorm(1000, mu = c(0, 0), Sigma = matrix(c(1, .5, .5, 1), 2))
  bivn2 &lt;- mvrnorm(1000, mu = c(0, 0), Sigma = matrix(c(1.5, 1.5, 1.5, 1.5), 2))
  
  # now we do a kernel density estimate
  bivn.kde &lt;- kde2d(bivn[,1], bivn[,2], n = 50)
  bivn.kde2 &lt;- kde2d(bivn2[,1], bivn[,2], n = 50)
  
  # fancy perspective
  persp(bivn.kde, phi = 45, theta = 30, shade = .1, border = NA)
  par(new=TRUE)
  persp(bivn.kde2, phi = 45, theta = 30, shade = .1, border = NA)
  </code></pre>
  
  <p>Which doesn't look very good, I guess I have to just play around with the axis and stuff.
  But if I try a similar approach with the contour the plots do not overlap. They are simply replaced:</p>
  
  <pre><code># fancy contour with image
  image(bivn.kde); contour(bivn.kde, add = T)
  par(new=TRUE)
  image(bivn.kde2); contour(bivn.kde, add = T)
  </code></pre>
  
  <p>Is this the best approach to what I want or am I just making it hard on myself? Any suggestions are welcome. Thank you!</p>