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(
yaxis = dict(
zaxis = dict(
title=‘Probability’ )),
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)

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 for a simple example of using intensity.

Hope that helps!

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


1 Like