1

I am trying to get a custom color scale for the heatmap that I am going to generate for the data similar to below one:

df=pd.DataFrame({"x": [1,2,3,4,5,6,7],"y": [1,2,3,4,5,6,7], "res":[0,5,5,10,5,15,20]})

The color condition would be:

Grey: for res <= 0, Yellow: for res >0, Orange: for res >5, Red: for res >10 etc.

I have tried seaborn heatmap but not able to set the conditioned custom color scale. Any clue would be greatly appreciated. Thanks!

rpanai
  • 12,515
  • 2
  • 42
  • 64
  • Do you mind to show us some code? – rpanai Feb 11 '20 at 18:47
  • You can build one following this [link](https://plot.ly/python/v3/colorscales/) – rpanai Feb 11 '20 at 19:03
  • See [this post](https://stackoverflow.com/questions/9707676/defining-a-discrete-colormap-for-imshow-in-matplotlib) about how to build a colormap with associated boundarynorm. The post is for 2 colors, more colors just means adding to the list of colors and of boundaries. – JohanC Feb 11 '20 at 19:22

1 Answers1

0

since you tagged plotly, you can find an example on how to create a custom colorscale here https://plot.ly/python/colorscales/#constructing-a-discrete-or-discontinuous-color-scale - but reading through the whole page is useful (and the heatmap tutorial is here https://plot.ly/python/heatmaps/).