'How to get bar colors of multiple traces from bar chart?

I created a bar chart with multiple traces using a loop. The colors of each trace are assigned by plotly automatically. Now chart is done, how to get colors of all traces? I needed to assign these same colors to another scatter plot inside subplots to make color consistent. Thank you so much for your help.


for i in range (10):
            fig.add_trace(
                    go.Bar(
                        x=weights_df_best.index,
                        y=weights_df_best[col].values,
                        name = col,
                        text=col,
                        hoverinfo='text',
                        legendgroup = '1',
                        offsetgroup=0,
                        ),
                    row=1,
                    col=1,
                         )



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source