Skip to content
Prev 173791 / 398503 Next

persp plot + plotting grid lines

Building on Duncan's code, here's an approximation to the Matlab
'peaks' plot referred to by Pedro:

peaks <-  function(x, y) { 3 * (1-x)^2 * exp(-(x^2)-(y+1)^2) -
  10 * (x/5-x^3-y^5) * exp(-x^2-y^2) - 1/3*exp(-(x+1)^2-y^2)}

x <- y <- seq(-3,3,.1)
z <- outer(x,y, peaks)
z2 <- 10 * round(c(z) + abs(min(z)) + 1)
jet.colors = colorRampPalette(c("#00007F", "blue", "#007FFF",
    "cyan", "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"))
color <- jet.colors(160)[z2]

library(rgl)
persp3d(x,y,z, color=color, smooth=FALSE)
surface3d(x,y,z+0.001, front="lines", back="culled")



Kingsford Jones
On Sat, Mar 14, 2009 at 3:51 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote: