Black Lives Matter. Please consider donating to Black Girls Code today.

Heatmap with asymmetric values

Hi,

I have a big dataset with values ranging from -1 to 1. I am able to plot them but I cannot see the small values like for example 0.0003. I would like to see those in a different color. Is that possible?

https://plot.ly/~petya.vasileva/18/

Try and change the colorscale to a logarithmic scale. Visualizing values that are orders of magnitudes apart are more easily compared on a logarithmic scale.

2 Likes

You can also define you own colorscale if you wish to highlight a specific data range, as described here https://plot.ly/python/colorscales/#custom-discretized-heatmap-colorscale and here https://plot.ly/python/colorscales/#custom-heatmap-colorscale (when you define the colorscale the data values do not have to be regularly spaced). Existing colorscales can be inspected like

>>> import plotly.express as px                                                                                               
>>> px.colors.diverging.RdBu                                                                                                  
['rgb(103,0,31)', 'rgb(178,24,43)', 'rgb(214,96,77)', 'rgb(244,165,130)', 'rgb(253,219,199)', 'rgb(247,247,247)', 'rgb(209,229,240)', 'rgb(146,197,222)', 'rgb(67,147,195)', 'rgb(33,102,172)', 'rgb(5,48,97)']
2 Likes

Thanks a lot for the suggestions.
I tried with the colorscale and it doesn’t work.
The only way I could make it work was to make all values logarithmic and then set up colorscale.
I am going to give it another try because it is not exactly what I need.

Hi @petya what do you mean by “it does not work” ? Please post here the code which you’ve been using (preferably using dummy data so that it’s reproducible) so that we can help you adapting it.