Home > OS >  matplotlib colorbar extend in different color
matplotlib colorbar extend in different color

Time:05-14

I have data in a 2D matrix I want to plt.colorbar(extend = "both"), I have set my data to be maxed at 100 and mined at -100, now I want to see where my data is more than 100 (it's a saturated region) so the extent of the colorbar has to be in a different color than the colorbar is there a way to set a cmap with the tips in a different color? Like <"yellow"|"seismic"|"orange">

CodePudding user response:

You can use colorbar with set_over and set_under

Seaborn's heatmap takes these colors into account when choosing either white or black for annotations.

import seaborn as sns

sns.heatmap(z, annot=True, fmt='d', cmap=cmap, norm=norm, cbar_kws={'extend': 'both'})

seaborn heatmap with over and under colors

  • Related