Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

How to activate contour lines in Mesh3D as in Surface3D?

Hello everyone,

I have a question if it is possible to activate contour lines in Mesh3D as in Surface3D?

According to the 3D Surface docoment, we can plot contour line by default like this:

Would it possible to do the same with 3D Mesh? I only found an option to show the contour line on hover.

Thank you so much in advance. :smiley:
Joe

@joe_ths
With such a definition of the Mesh3d contours:

fig = go.Figure(go.Mesh3d(x=x, 
                          y=y, 
                          z=z, 
                          i=I, 
                          j=J, 
                          k=K, 
                          contour_width=2, contour_color="#101010", contour_show=True,
                          intensity=z,
                          colorscale="curl"
                         ))
fig.update_traces(lighting=dict(ambient=0.8, diffuse=0.5, 
                                specular=0.5, roughness=0.5, 
                                fresnel=0.5))

the contours are displayed only on hover over a point. In fact it displays only the contour through the hovered point.

For meshes is recommended

to plot the triangle edges, to visualize the underlaying triangulation.
Namely:
if vertices is the array of 3d points, of shape (n, 3),
and faces is the array representing triangles (an array of shape (m,3) and type int),
then you can define the trace of triangle edges as follows:

tri_vertices= vertices[faces]
Xe = []
Ye = []
Ze = []
for T in tri_vertices:
    Xe += [T[k%3][0] for k in range(4)]+[ None]
    Ye += [T[k%3][1] for k in range(4)]+[ None]
    Ze += [T[k%3][2] for k in range(4)]+[ None]
       
#define the lines to be plotted
lines= go.Scatter3d(
            x=Xe,
            y=Ye,
            z=Ze,
            mode='lines',
            name='',
            line=dict(color= 'rgb(50,50,50)', width=1.5))