How to invert color of seaborn heatmap colorbar

前端 未结 4 1293
闹比i
闹比i 2021-01-30 23:10

I use an heatmap to visualize a confusion matrix. I like the standard colors, but I would like to have 0s in light orange and highest values in dark purple.

I managed to

4条回答
  •  孤独总比滥情好
    2021-01-30 23:23

    The default cmap is sns.cm.rocket. To reverse it set cmap to sns.cm.rocket_r

    Using your code:

    cmap = sns.cm.rocket_r
    
    ax = sns.heatmap(cm_prob,
                     annot=False,
                     fmt=".3f",
                     xticklabels=print_categories,
                     yticklabels=print_categories,
                     vmin=-0.05,
                     cmap = cmap)
    

提交回复
热议问题