Is it possible for multiple traces to share the same colorscale?

For different traces, even if I assign the same colormap (using a float array as color input), the colorscale will be different because of the different max and min values of each trace. Is there an easy way to plot them with a shared colorscale? I cannot plot them in the same trace because I need to style them differently. Thanks!

Not at the moment unfortunately.

Here’s how: https://codepen.io/etpinard/pen/YayPNd?editors=0010

1 Like

Thanks! This will work for me.

Had the same problem - used something like this:

col_mat_0 = np.array([[0,189,242],[0,45,114]]) #Has the colorscale values corresponding to 0 and 1
col_mat_1 = col_mat_0[0]+np.matmul(np.array(z_data.max(axis=1)).reshape(len(z_data.max(axis=1)),1),
np.array((col_mat_0[1]-col_mat_0[0])/z_data.max().max()).reshape(1,3))
col_mat_0 = col_mat_0[0]+np.matmul(np.array(z_data.min(axis=1)).reshape(len(z_data.max(axis=1)),1),
np.array((col_mat_0[1]-col_mat_0[0])/z_data.max().max()).reshape(1,3))
col_mat_1[0]

While using within the traces:

colorscale=[[0.0, β€˜rgb(%d,%d,%d)’%(col_mat_0[i][0], col_mat_0[i][1], col_mat_0[i][2])],
[1.0, β€˜rgb(%d,%d,%d)’%(col_mat_1[i][0], col_mat_1[i][1], col_mat_1[i][2])]],
showscale=(i==0),

You can subscribe to https://github.com/plotly/plotly.js/issues/3431 for the most up-to-date development info.