Highlight heatmap cell or change the color of a specific heatmap cell

Is it possible to highlight or change the color of a specific heatmap cell in Plotly, I have a requirement of accepting the user input and then highlight those cells on the heatmap. Any help would be greatly appreciated, thanks

2 Likes

You could add a second heatmap in front of the first, with all null (or NaN or None) except for the selected cells. Alternatively if itโ€™s a compact region youโ€™re highlighting you could make a layout.shape or a filled scatter line trace that encloses the selected region.

Thank you @alexcjohnson, I guess I will try the scatter layout and see how it goes.

hi alex
Im not undertanding exactly how could it work by adding a second heatmap in front of the first.
I would like to have the cells of -lets say- the diagonal of the dataframe for the heatmap without color.

My snippet is

    heatmap = px.imshow(heatdata,
                        y=y,
                        labels=dict(x=t2, y=t1),
                        text_auto='.5',
                        color_continuous_scale='Blues',
                        range_color=[0, max_offdiag],
                        aspect="auto")

just following up here - were you able to achieve this?