7

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

user1317221_G
  • 15,087
  • 3
  • 52
  • 78
user3000568
  • 81
  • 1
  • 3

1 Answers1

4

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))

enter image description here

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)

enter image description here

user1317221_G
  • 15,087
  • 3
  • 52
  • 78
  • Thanks, but I still don't get it. I was looking at col.regions... but how do you control which variable determines the color? I now see that light.source also plays a role.. Anyway, I am trying to control the color depending on some function applied to the tick values of the x-axis (the x varible). What is the best way to do this? – user3000568 Nov 21 '13 at 23:20
  • @user1317221_G: The OP asked for creating color "strips" along either x or y values, not by the z values that drape=TRUE supports. – IRTFM Nov 22 '13 at 01:48
  • hey just realised your comment, sorry I didn't fully get your Q. I do not think this is possible without a hack to the source..;. – user1317221_G Nov 22 '13 at 08:48