Skip to content

Mismatch between legend and line colors when using uppercase css colors #6883

Closed
@Coding-with-Adam

Description

@Coding-with-Adam

Bug originally reported on the forum.
When using css colors with the first letter capitalized, a line chart will show all lines as black, although the legend will adhere to the correct css colors.

Codepen JS code

image

Plotly.py code:

import plotly.express as px

css_colors = ['AntiqueWhite', 'Aqua', 'Aquamarine', 'Black', 'Red']
# css_colors = [color.lower() for color in css_colors]

df = px.data.gapminder()
print(df['continent'].unique())
color_discrete_map = {subject: css_colors[i] for i, subject in enumerate(sorted(df['continent'].unique()))}
fig = px.line(df, x="year", y="lifeExp", color='continent', color_discrete_map=color_discrete_map)
fig.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething brokensev-1blocker

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions