Open
Description
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.
Activity
kMutagene commentedon Apr 7, 2025
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.