Surface plot; inverse color scale

Very new to plotly, so upfront apology if this is trivial. Iโ€™m using python plotly with spyder:

import plotly.graph_objects as go
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])

The z values are all negative (itโ€™s just how the function works). I want to use a different color scale:

fig = go.Figure(data=[go.Surface(z=z, x=x, y=y, colorscale='reds')])

but the colors are the reverse from what I want. Max value is dark red and min value is white. Iโ€™d like to reverse. I know I can negate the z values to get the color scheme I want, but then the plot is inverted and I have a difficult time rotating it the way I want. Iโ€™d rather somehow reverse the colors. Is this readily done?

Hi @cxn welcome to the forums.

You can reverse all built in colorscale by appending โ€œ_rโ€ to the name, see also: Built-in continuous color scales in Python

Wow, fantastic! Result is great. Thanks!!

1 Like