Changing the surface coloring (using lattice::wire

2020-07-11 09:09发布

问题:

I am using lattice::wireframe to create a surface. I need to change the coloring so that it depends on the x or y variable (instead of on z). How should this be done? The documentation says that the color is automatically chosen to depend on the height (e.g. z).

Thanks! Georgi

回答1:

Use col.regions

wireframe(volcano, drape = TRUE,
       aspect = c(61/87, 0.4),
       light.source = c(10,0,10), 
       col.regions = colorRampPalette(c("blue", "pink"))(100))

As per your coment and with inspiration from @DWin who I am sure will do a better job here, perhaps with ?persp you can get closer to what you want.

> persp(x, y, z, theta = 135, phi = 30, col = colorRampPalette(c("blue", "pink"))(9500), scale = FALSE,
+       ltheta = -120, shade = 0.75, border = NA, box = FALSE)



标签: r lattice