Skip to content

non-dynamic textfont color when using continuous color scales #3196

Closed
plotly/plotly.js
#5666
@jarvas24

Description

@jarvas24

Current Behavior (plotly version 4.14.3)

When using the text property in a bar trace with a continuous color scale, the textfont.color is static; all bars use the same text color, which results in difficult to read text for some bars (far right bar in screenshot).

import plotly.express as px
x = list(range(1, 10))
px.bar(x=x, y=x, color=x, text=[str(i) for i in x])

image

Expected/Desired Behavior

The text font color should be dynamic (dark text on light colored bars, light text on dark bars), just like the hover text. Bar traces with discrete colorscales already have this behavior:

import plotly.express as px
x = list(range(1, 10))
px.bar(x=x, y=x, color=[str(i) for i in x], text=[str(i) for i in x], color_discrete_sequence=px.colors.sequential.Plasma)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions