[R] plotting a marginal distribution on the plane behind a persp() plot

2013-10-15 Thread Colin Rowat
R'istas: I am trying to plot a marginal distribution on the plane behind a persp() plot. My existing code is: library(MASS) X <- mvrnorm(1000,mu=c(0,0),Sigma=matrix(c(1,0,0,1),2)) X.kde <- kde2d(X[,1],X[,2],n=25) # X.kde is list: $x 1*n, $y 1*n, $z n*n persp(X.kde,phi=30,theta=60,xlab="x_b",

Re: [R] plotting a marginal distribution on the plane behind a persp() plot

2013-10-18 Thread Colin Rowat
s(X.kde$z) mass <- sum(marg) lines(trans3d(x=X.kde$x, y=rep(X.kde$y[25],25), z=marg/mass, pmat=res),col="green",lwd=2) detach(package:MASS) > -Original Message- > From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > Sent: 15 October 2013 18:00 > To: Colin R