How to invert color of seaborn heatmap colorbar
To expand on Ben's answer, you can do this with most if not any color map.
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
X = np.random.random((4, 4))
sns.heatmap(X,cmap="Blues")
plt.show()
sns.heatmap(X,cmap="Blues_r")
plt.show()
sns.heatmap(X,cmap="YlGnBu")
plt.show()
sns.heatmap(X,cmap="YlGnBu_r")
plt.show()
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)