Assign color bar to x axis

Hello, in a surface plot, is there a way to define the color of the surface (continuous) and the color bar in relation to the x axis data instead of the default z axis?

Hi @DennisPureza welcome to the forum! Yes this is possible, using the surfacecolor attribute of go.Surface. For example

import plotly.graph_objects as go
import numpy as np
x, y = 4 * np.pi * np.mgrid[0:1:20j, 0:1:20j]
z = np.sin(x)
fig = go.Figure(go.Surface(x=x, y=y, z=z, surfacecolor=x))
fig.show()

Thank you! It worked perfectly!