[R] add points to wireframe

bbolker bolker at ufl.edu
Wed Sep 26 18:33:15 CEST 2007




marcg wrote:
> 
> Hello
> 
> with follwing code I want to produce the wireframe and add some points on
> it:
> 
> wireframe(z ~ x * y, data=dem, aspect = c(1, .5),
>           scales = list(arrows = FALSE),
>           panel.3d.wireframe = function(x, y, z,...) {
>               panel.3dwire(x = x, y = y, z = z, ...)
>               panel.3dscatter(x = x,
>                               y = y,
>                               z = z, data=ramm
>                               ...)
>           })
> 
> 

 You're missing a comma after data=ramm   ...
  But even when I fix that, I don't get what you want --
I don't the data argument gets used here.

xy <- expand.grid(1:10,1:10)
names(xy) <- c("x","y")
z <- with(xy,2*x+y)
dem <- data.frame(xy,z)
xy2 <- data.frame(x=runif(8,1,10),y=runif(8,1,10))
z2 <-  with(xy2,rnorm(8,2*x+y,sd=1))
ramm <- data.frame(xy2,z2)

wireframe(z ~ x * y, data=dem, aspect = c(1, .5),
          scales = list(arrows = FALSE),
          panel.3d.wireframe = function(x, y, z,...) {
              panel.3dwire(x = x, y = y, z = z, ...)
              panel.3dscatter(x = x,
                              y = y,
                              z = z,
                              data=ramm,
                              ...)
          })


  Making x, y, z in the panel.3dscatter call into ramm$x, ramm$y, ramm$z
gives an error.
-- 
View this message in context: http://www.nabble.com/add-points-to-wireframe-tf4522433.html#a12904664
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list