I wanted a heatmap of confusion matrix which generates colors based on percentages of each class. For example the highest percentages goes black and the others get lighter based on their percentages(higher percentages = darker color). I tried changing vmin and vmax, but colors get changed based on 'counts' value not grouped_percentages.
categories = ['a', 'b', 'c']
group_percentages = []
counts = []
for i in range (len(cf)):
for j in range(len(cf)):
group_percentages.append(cf[j,i]/np.sum(cf[:,i]))
counts.append(cf[j,i])
group_percentages = ['{0:.2%}'.format(value) for value in
group_percentages]
counts = ['{0:0.0f}'.format(value) for value in
counts]
labels = [f'{v1}\n{v2}' for v1, v2 in zip(group_percentages, counts)]
labels = np.asarray(labels).reshape(3,3,order='F')
sns.heatmap(cf, annot=labels, fmt='', xticklabels=categories, yticklabels=categories, cmap='Greys', vmax=100, cbar=False)
output:
As you can see eventhough I set vmax to 100, cf[0,0] is 100%, but the color in the heatmap on gray, but cf[1,1] is 89% and its color is black.

