Unique colormap for different 3D surfaces

Hi,

I have different surfaces that I want to display in one 3D graph as one big surface, but the problem is that they each have their own colorscale. How can I get a unique colorscale for the whole surface (composed of all the subsurfaces) ?

Here is my code:

    surface_involute1_uniform = go.Surface(x=x_involute_uniform, y=z_uniform_involute, z=y_involute_uniform, showscale=False)
    surface_involute2_uniform = go.Surface(x=-x_involute_uniform, y=z_uniform_involute, z=y_involute_uniform, showscale=False)
    surface_parab1_uniform = go.Surface(x=x_parab_uniform, y=z_uniform_parab, z=y_parab_uniform, showscale=False)
    surface_parab2_uniform = go.Surface(x=-x_parab_uniform, y=z_uniform_parab, z=y_parab_uniform, showscale=False)

    surface_involute1_inc = go.Surface(x=x_involute_var, y=z_inc_involute, z=y_involute_var, showscale=False)
    surface_involute2_inc = go.Surface(x=-x_involute_var, y=z_inc_involute, z=y_involute_var, showscale=False)
    surface_parab1_inc = go.Surface(x=x_parab_var, y=z_inc_parab, z=y_parab_var, showscale=False)
    surface_parab2_inc = go.Surface(x=-x_parab_var, y=z_inc_parab, z=y_parab_var, showscale=False)

    surface_involute1_dec = go.Surface(x=x_involute_var, y=z_dec_involute, z=y_involute_var, showscale=False)
    surface_involute2_dec = go.Surface(x=-x_involute_var, y=z_dec_involute, z=y_involute_var, showscale=False)
    surface_parab1_dec = go.Surface(x=x_parab_var, y=z_dec_parab, z=y_parab_var, showscale=False)
    surface_parab2_dec = go.Surface(x=-x_parab_var, y=z_dec_parab, z=y_parab_var, showscale=False)

    data = [surface_involute1_uniform, surface_involute2_uniform,
            surface_involute1_inc, surface_involute2_inc,
            surface_involute1_dec, surface_involute2_dec,
            surface_parab1_uniform, surface_parab2_uniform,
            surface_parab1_inc, surface_parab2_inc,
            surface_parab1_dec, surface_parab2_dec]

    layout = go.Layout(
        title='Parametric Plot',
        scene=dict(
            xaxis=dict(
                gridcolor='rgb(255, 255, 255)',
                zerolinecolor='rgb(255, 255, 255)',
                showbackground=True,
                backgroundcolor='rgb(230, 230,230)'
            ),
            yaxis=dict(
                gridcolor='rgb(255, 255, 255)',
                zerolinecolor='rgb(255, 255, 255)',
                showbackground=True,
                backgroundcolor='rgb(230, 230,230)'
            ),
            zaxis=dict(
                gridcolor='rgb(255, 255, 255)',
                zerolinecolor='rgb(255, 255, 255)',
                showbackground=True,
                backgroundcolor='rgb(230, 230,230)'
            )
        )
    )

    fig = go.Figure(data=data, layout=layout)
    plotly.offline.plot(fig, filename='Parametric_plot')

Thank you,

Antoine

Hey @a.zurcher ,

You can define common colorscale for all of your surface traces.

Please see โ€œcoloraxisโ€ and โ€œcolorscaleโ€
https://plotly.com/python/reference/surface/

Hereโ€™s an example

import plotly.graph_objs as go

z1 = [
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
]

z2 = [
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
    [1,1,1,1,1,1],
]



z2 = [[zij-11 for zij in zi] for zi in z1]



fig = go.Figure()

fig.add_trace(go.Surface(z=z1,showscale=False, coloraxis='coloraxis' ))
fig.add_trace(go.Surface(z=z2,showscale=True, coloraxis='coloraxis' ))
    
fig.update_layout(coloraxis = dict(colorscale='Viridis', cmin =-10, cmax=1))  

fig.show()

Thanks a lot!