On Aug 31, 2008, at 7:21 PM, dxc13 wrote:
>
> Dear list,
>
> I am trying to construct a perspective plot of a 2D triangle, or
> pyramid. I
> can easily do the one dimensional plot (code below), but I can't
> figure out
> how to do it in a perspective plot for two input variables. Does
> anyone
> have a simple solution?
>
> Thanks!
> Derek
>
> #code for a triangle
> u <- seq(-1,1,.001)
> tri <- (1-abs(u))
> plot(tri~u,type="l",main="Second Iteration Kernel: Two Input
> Variables",lwd=2,
> xlab="x",ylab="y",col="blue")
You probably don't want to have quite so many points in your parameter
variables.
This is not a correct solution, but maybe it will get you further along:
u <- seq(-1,1,.1)
v <- seq(-1,1,.1)
z <- outer(u,v,f)
f <- function(u,v) { val <- 1 -abs(u) -abs(v) }
z <- outer(u,v,f)
persp(u,v,z, xlim = c(-2,2), phi = 30, theta=30)
For one complete solution fry ?ifelse
--
David Winsemius