# Unique colormap for different 3D surfaces

**URL:** <https://community.plotly.com/t/unique-colormap-for-different-3d-surfaces/62345>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [March 27, 2022, 11:35am UTC](https://community.plotly.com/t/unique-colormap-for-different-3d-surfaces/62345 "2022-03-27T11:35:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![a.zurcher](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@a.zurcher](https://community.plotly.com/u/a.zurcher)\
**Post date:** [March 27, 2022, 11:35am UTC](https://community.plotly.com/t/unique-colormap-for-different-3d-surfaces/62345/1 "2022-03-27T11:35:29Z")

</div>

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:

```auto
    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

---

<div class="post-metadata">

**Author:** ![akroma](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/akroma/32/20346_2.png) [@akroma](https://community.plotly.com/u/akroma)\
**Post date:** [March 27, 2022, 1:45pm UTC](https://community.plotly.com/t/unique-colormap-for-different-3d-surfaces/62345/2 "2022-03-27T13:45:06Z")

</div>

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/](https://plotly.com/python/reference/surface/)

Here’s an example

```auto
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()

```

 ![common_colorscale](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/4/1/41512cf6e7242b45c6cb4871ef251f554f66ca7e.png)

---

<div class="post-metadata">

**Author:** ![a.zurcher](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@a.zurcher](https://community.plotly.com/u/a.zurcher)\
**Post date:** [March 27, 2022, 2:26pm UTC](https://community.plotly.com/t/unique-colormap-for-different-3d-surfaces/62345/3 "2022-03-27T14:26:33Z")

</div>

Thanks a lot!
