Single-axis color scale with mesh3D

Hello everyone,

I am looking to add a colorscale with a colorbar according only one axis (z) on a Mesh3D plot but i can’t figure how to do it.

Here is the first code that I have:

layout = go.Layout(
scene = dict(
xaxis = dict(
title=‘Time’),
yaxis = dict(
title=‘Km’),
zaxis = dict(
title=‘Probability’ )),
width=700,
margin=dict(
r=20, b=10,
l=10, t=10)
)

trace = go.Mesh3d(x=x,y=y,z=z,opacity=1)

fig = go.Figure(data=[trace], layout=layout)
plotly.offline.plot(fig,filename=‘test.html’)

My final purpose is to have somethink like this but with Mesh3D :

Thanks so much in advance!

Hi @gvieu,

I think you could do this by specifying a colorscale and setting the intensity property to be identical to the z vertex coordinates. See https://plot.ly/python/3d-mesh/#mesh-tetrahedron for a simple example of using intensity.

Hope that helps!
-Jon

Hi @jmmease,

Thanks for your help, it works perfectly with your specification :

trace = go.Mesh3d(x=x,y=y,z=z,opacity=1, intensity=z, colorscale=‘Viridis’)

Guillaume

1 Like