Reputation: 207
I am trying to plot a 3d graph by using plot_ly
x = c(1:5)
y = c(1:5)
z = matrix(c(1:20),nrow=5)
z_col = matrix(c(31:50),nrow=5)
plot_ly(x = ~ x, y = ~ y, z= ~ z) %>% add_surface()
The color of the surface will depend on z value. However, I want that color to depend on an external variable (z_col). I have tried to add in the color manually, but it doesn't work:
plot_ly(x = ~ x, y = ~ y, z= ~ z, color = ~ z_col) %>% add_surface()
Is there any way for me to do it ?
Upvotes: 0
Views: 92
Reputation: 24262
Use surfacecolor
instead of color
:
plot_ly(x = ~ x, y = ~ y, z= ~ z, surfacecolor = ~ z_col) %>% add_surface()
Upvotes: 1