Python sns heatmap plot, need to show a text for legend y axis
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I would like to show a text label that corresponds to the color. If I could populate the legend with a list that would add provide lable llke ["na","poor","average","good", "excellent"]

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

test_data = {
'Java':[1,  5, 3, 3],
'COBOL':[2, 1, 1, 4],
'C':    [2, 3, 2, 1],
'C#':   [2, 2, 3, 2],
'.NET': [3, 1, 3, 4],
'Assembler':[3, 3, 2, 1],
'Python':  [ 4, 3, 3, 4]
}

df = pd.DataFrame(test_data)
plt.xticks(fontsize="9")
plt.yticks(fontsize="9")
plt.yticks(np.arange(4),['Tom', 'Dick', 'Sue','Ben']) 
print(df)
sns.heatmap(df,cmap="YlGnBu",annot=True, yticklabels = (['Tom', 'Dick', 'Sue','Ben']))
plt.show()
Tags
python3

Crowdsource coding tasks.

1 Solution

Winning solution

Solution

You can find the complete script here: https://paste.ofcode.org/TM8gGtZGDt9Bzpww4a2x8q

Thank you, Vladimir.

Thank you!
broadreach 5 months ago