Setting line color with seversl dropdowns

Hi @MichaelLBM, welcome to the forums.

I did some testing. It seems, that plotly has some problems with capital letters within the color strings. Try converting your colors to str.lower() and try again.

css_colors = [color.lower() for color in css_colors]

I think, this might be a bug.

import plotly.express as px

css_colors = ['AntiqueWhite', 'Aqua', 'Aquamarine', 'Black', 'Blue', 'BlueViolet', 'Brown', 'BurlyWood', 'CadetBlue', 'Charteuse', 'Chocolate', 'Coral', 'CornflowerBlue',
              'Crimson', 'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen', 'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkRed', 'DarkOrange',
              'DarkSlateGray', 'DeepPink', 'DodgerBlue', 'HotPink', 'GreenYellow', 'Purple', 'Yellow', 'Red']

css_colors = [color.lower() for color in css_colors]

# colors
color_discrete_map = {subject: css_colors[i] for i, subject in enumerate(sorted(df['continent'].unique()))}

df = px.data.gapminder()
fig = px.line(df, x="year", y="lifeExp", color='continent', color_discrete_map=color_discrete_map)
fig.show()


mrep colors

1 Like