I have been following a tutorial and set up a scatterplot first with px.scatter:
df_iris = px.data.iris()
df_iris
fig = px.scatter(df_iris, x="sepal_width", y= "sepal_length", color="species",size="petal_length",hover_data=['petal_width'])
fig.update_layout(height=1000)
I then tried to do the same thing with go.Scatter() with this:
#Mere detaljeret plot
fig = go.Figure()
fig.add_trace(go.Scatter(
x=df_iris.sepal_width,
y=df_iris.sepal_length,
mode='markers',
marker_color=df_iris.species) )
fig.update_layout(height=1000)
fig
#marker_color=df_iris.species),
I get the error:
Invalid element(s) received for the ācolorā property of scatter.marker
I have been reading through the documentation, but I donāt see a way to specify the color by a column with go.Scatter() similar to px.Scatter().
Is this possible?
In addition to the solution below, check out how we used Plotly Studio to build an app that shows all the Plotly color scales.