Creating colorscale only for Z axis

I have a map created with 3d mesh plot, that has my location on x axis, day on y, and frequency on z. I want to add a color scale for the Z axis. But I can’t seem to properly work with the color scale to the all map, and neither to only z axis (that it is what I want). My code is the following:

place<-c(“here”, “there”, “far away”)

z<-dcast(d, day~place, fill=0)
d_long <- melt(z, id.vars=c(“day”))

p<-plot_ly(data = d_long, x = ~i_DiaAlerta, y = ~variable, z = ~value, type=“mesh3d”,
color = c(0, 10, 20, 30),
intensity = c(0, 10, 20, 30),
showscale = TRUE)


Hey @inestesepelaez

I may have read this wrong, but are you wanting to set color = ~value

Yes, i wish to only apply the colorscale to Z value.

I am having exactly the same problem and also did not manage to find a solution so far

I was facing the same problem and it was not clear for me from the (Reference Documentation - mesh3d-intensity. After a while I realize that the intensity needs to be an array of the same size as the coordinate arrays. If you want the intensity to change alongside the z axis just set the intensity to the x-coordinate array. In JS it looks like:

var trace = {
    x : xArray,
    y : yArray,
    z : zArray,
    colorscale: [[0, 'rgb(0, 255, 0)'], [1, 'rgb(255, 0, 0)']], //or a constant, e.g.: 'YIGnBu',
    intensity: xArray,
    type: 'mesh3d'