Multiple traces with same names but different legend

Can multple traces have the same name, but have different color on graph and in legend?

Yes, did you try it?

import plotly.graph_objects as go
import numpy as np

def data():
    return np.random.randint(0, 255, 10)

fig = go.Figure()
traces = [go.Scatter(x=data(), y=data(), name='the_name', mode='markers', marker={'color': color}) for color in ['red', 'green', 'blue']]

fig.update_layout(width=500, height=500)


1 Like

yes, but thanks. I had a mistake in my code and i noticed it only after posting question. thanks.