Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Apply "color groups" for multiple traces

I have a figure with 3 line scatters, and for each of them I want to mark a specific point. I’m doing so by adding for each another scatter with single point in the x, y I want.
I would like for the scatter and the single-point scatter to have the same color, which I can define explicitly but I also want to be able to not decide on the colors in the creation of the figure and be able to later control it using themes/templates.

So I’m looking for a solution to put two scatter traces in the same “color group” without explicitly define the color.

import numpy as np
import plotly.graph_objects as go

size = 10

x = list(range(size))

y = {
    'a': np.random.rand(size),
    'b': np.random.rand(size),
    'c': np.random.rand(size)
}

index_to_higlight = {
    'a': 2,
    'b': 5,
    'c': 1
}

fig = go.Figure()
for plot in ['a', 'b', 'c']:
    # Both scatters should have the same color! 
    # but colors should be editable later using templates
    fig.add_trace(go.Scatter(x=x, y=y[plot]))
    fig.add_trace(go.Scatter(x=[x[index_to_higlight[plot]]], 
                             y=[y[plot][index_to_higlight[plot]]], 
                             mode='markers', marker_size=15, showlegend=False))