Black Lives Matter. Please consider donating to Black Girls Code today.

Mesh3d colour scale

Hi

Can anyone help?

I am trying to create a mesh3D plot in plotlyR using R studio but I am having problems with how to create a colour scale to my mesh.

I have a nice mesh plot using the code,

p <- plot_ly(
x = points[, 1], y = points[, 2], z = points[, 3],

i = faces[, 1]-1, j = faces[, 2]-1, k = faces[, 3]-1,

type = “mesh3d”,

facecolor = “red”,
intensity = intensity,
colorscale = “red”,
showscale = TRUE
)

p

I’m not very sure what face colour does, intensity does or colour scale does, but I want to map a colour scale onto the mesh based on a value called bi, that I have measured for each point (ie, each x = points[, 1], y = points[, 2], z = points[, 3] point has a value of bi assigned to it in my dataframe). And I want to scale the colour where

vert$colour[vert$bi<= 0.5] <- "red"
vert$colour[vert$bi> 0.5 & vert$bi<=1.5] <- "green"
vert$colour[vert$bi>= 1.5] <- “purple”

or similar in a blending contour fashion.

Any thoughts on how to plot this?

Many thanks
All help welcome

Neil

here is the plot if that helps

https://plot.ly/~neilsrini/1377/points-2-vs-points-1/

You could use intensity. Other options are also illustrated in this JS demo.