Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jarvas24 opened this issue May 13, 2021 · 3 comments · Fixed by plotly/plotly.js#5666
Closed

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

jarvas24 opened this issue May 13, 2021 · 3 comments · Fixed by plotly/plotly.js#5666

Comments

@jarvas24
Copy link

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

@ArkaprabhaChakraborty
Copy link

Is anyone working on this? If not then I want to work on this.

@nicolaskruchten
Copy link
Contributor

No one is working on it as far as I know, and we'd love the help! The right place to solve this is in the underlying Javascript library Plotly.js. We've actually got code that does this for pie charts and treemaps I believe, so it may be quite straightforward to port it to bars :)

@archmoj or @alexcjohnson can advise.

@nicolaskruchten
Copy link
Contributor

Looks like this is getting fixed in plotly/plotly.js#5666 actually :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants