Message-ID: <18FF9FCF-41E1-45B5-88CB-B7B06AAC9597@comcast.net>
Date: 2012-08-25T05:16:50Z
From: David Winsemius
Subject: plot curve on surface
In-Reply-To: <1345800891.76196.YahooMailNeo@web193404.mail.sg3.yahoo.com>
On Aug 24, 2012, at 2:34 AM, Michael Meyer wrote:
>
>
> Greetings,
>
> I would like to plot a curve (in color red) on a surface in a 3D plot.
> Say
>
> x <- as.vector(seq(-1,1,0.2))
> dim(x) <- c(length(x),1)
> y <- as.vector(seq(-1,1,0.2))
> dim(y) <- c(1,length(y))
>
> z <- x%*%y # (x_iy_j)
>
> # 3D plot of z(x,y)=xy:
> persp(x,y,z)
>
> Now I would like to plot the curve z=z(x,x) in red on this surface.
> How do I do that?
>
persp(x,y,z) -> res
points( trans3d(x, x, x^2, pmat = res), col = "red")
lines( trans3d(x, x, x^2, pmat = res), col = "red")
--
David Winsemius, MD
Alameda, CA, USA