celestialgod

wireframe without gird

Mar 25th, 2015
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.80 KB | None | 0 0
  1. library(dplyr)
  2. library(data.table)
  3. library(magrittr)
  4. library(tidyr)
  5. library(lattice)
  6. xygrid = expand.grid(x = -30:30, y = -30:30)
  7. dat = xygrid %>% mutate(z1 = x+3*y, z2 = 0)
  8. dat_piled = dat %>% gather(group, z_value, z1:z2) %>% tbl_dt(FALSE)
  9. cols = c("cyan", "yellow")
  10.  
  11. panel.custom = function(x, y, z, xlim, ylim, zlim, xlim.scaled,
  12.   ylim.scaled, zlim.scaled, ...) {
  13.   panel.3dwire(x = x, y = y, z = z, xlim = xlim, ylim = ylim,
  14.     zlim = zlim,xlim.scaled = xlim.scaled,ylim.scaled = ylim.scaled,
  15.     zlim.scaled = zlim.scaled, col = "transparent", ...)
  16.       }
  17.  
  18. wireframe(z_value ~ x + y, dat_piled, groups=group,
  19.   par.settings = simpleTheme(col = cols),
  20.   auto.key = list(columns = 2, text = paste("z", 1:2),
  21.     rectangles = TRUE, points = FALSE),
  22.   panel.3d.wireframe = panel.custom )
Advertisement
Add Comment
Please, Sign In to add comment