Hi all,
I am creating two instances of a scatter plot and appending them to the same graph object and plotting it. Each scatter trace gets an x and a y array as well as the name, every other parameter is default. When they get plotted they get assigned a color each. I want the two scatter plots to be the same color.
I could solve this by creating a dictionary of colors and then choosing a random color and assigning it to both scatter traces but I am curious if there is a way to do it automatically and use default auto assigned color of one trace as the color of another trace.
I tried grouping them into a legend group but it doesn’t give me the color solution.
Below is a simplified code of what I’m doing:
plot_trace1 = go.Scatter(
x=xi,
y=yi,
mode='lines',
name=str(i['Depth']),
legendgroup =str(i['Depth'])
)
plot_trace2 = go.Scatter(
x=i['x_pts'],
y=ypts,
mode='markers',
name=str(i['Depth']),
legendgroup =str(i['Depth'])
)
plot_data.append(plot_trace1)
plot_data.append(plot_trace2)
plot_layout = {'title': 'Comparison Plot',
'legend': dict(x=0, y=-0.5, traceorder='grouped'),
'xaxis':dict(
title='Position (mm)',
tickmode='linear',
ticks='outside',
dtick=maxx/5,
ticklen=8,
tickwidth=1,
tickcolor='#000'
),
'yaxis':dict(
title='Reading',
tickmode='linear',
ticks='outside',
dtick=maxy/10,
ticklen=8,
tickwidth=1,
tickcolor='#000'
),
}
MC_fig = go.Figure(data=plot_data, layout=plot_layout)
Thanks,
Mike