Skip to content

Annotated Heatmap: automatic font color #485

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

Open
u3r opened this issue Mar 28, 2025 · 1 comment
Open

Annotated Heatmap: automatic font color #485

u3r opened this issue Mar 28, 2025 · 1 comment

Comments

@u3r
Copy link

u3r commented Mar 28, 2025

Given an annotated heatmap I would expect the cell text to contrast with the cell color.
(Not doing so leads to the readability issues in the current documentation/example of Annotated Heatmap: https://plotly.net/simple-charts/heatmaps.html)

A good contrast is shown and discussed on the python side of plotly: plotly/plotly.py#1300

When I did not find a way to do that, I looked at the implementation of AnnotatedHeatmap.
Here the configuration of the annotations is not dependent on the actual cell values - I could only apply a workaround of setting a background color.
I did not find/check the actual layouting step if there is a better place to compute correct font color.

@kMutagene
Copy link
Collaborator

Hey @u3r, thanks for reporting this.

Our methods have no access to the computed colors on the used colorscale. Colors are assigned by the plotly.js renderer in the browser. This means that for automatic font color, we would need a full implementation of all pre-defined color scales, as well as custom colorscales that can return computed color values based on the range of data. This is error prone, e.g. when the base plotly.js changes/adds a named color scale, we always have to fully implement it as well - not an ideal solution and i wonder how the python lib does it.

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

No branches or pull requests

2 participants