The perspp function does not do plotting, it does conversion. Save the
results you get from perspp and use than as the first argument to
functions like points, lines, text, etc.
See the examples for perspp as well.
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow@intermountainmail.org
(801) 408-8111
> -----Original Message-----
> From: s-news-owner@lists.biostat.wustl.edu
> [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Kim Elmore
> Sent: Friday, August 31, 2007 10:59 AM
> To: S-News
> Subject: [S] persp amd perspp
>
> I'm creating surfaces in 3D and then adding noise to the
> points defining the surface. I'd like to plot the surface,
> along with points (using
> perspp) showing noisy values as points on a perspective plot
> of the surface. I've created a data frame containing all the
> x, y and z values.
> I also create a matrix with the smooth z-values and plot it
> with persp(). syn.df contains the synthesized surface with
> all the x, y, and z values, one triplet on each row, and
> syn.mat contains all the z values in a matrix. syn.pts
> contains the x values ranging from -5 to 5 incremented by 1.
> I thought this would do it:
>
> synmat.fun <- function(x, y, dzdx = 1.5, dzdy = 2.5){
> z <- 4 - dzdx * x^2 - dzdy * y^2
> return(z)
> }
> syn.df <- data.frame(x= rep(-5:5, each = 11), y = rep(-5:5,
> 11), z = rep(NA, 121)) syn.df$z <- synmat.fun(syn.df$x,
> syn.df$y syn.pts <- seq(from = -5, to = 5) syn.mat <-
> outer(syn.pts, syn.pts, synmat.fun) info.p <- persp(x =
> syn.pts, y = syn.pts, syn.mat) perspp(syn.df$x, syn.df$y,
> syn.df$z + rnorm(length(syn.df$z), info.p)
>
> Everything works fine, yet the perspp() function never plots
> the points for me: nothing happens when I call it except that
> I see two elements of a list, x, and y, that show the 2D x
> and y projected locations of the points to be plotted, but no
> points appear. I've done nothing strange with par() so I'm
> not sure what to try next.
>
> Kim Elmore
> --------------------------------------------------------------------
> This message was distributed by
> s-news@lists.biostat.wustl.edu. To unsubscribe send e-mail
> to s-news-request@lists.biostat.wustl.edu with the BODY of
> the message: unsubscribe s-news
>
|