I'm trying to create a 2D heatmap with a very basic Pandas dataframe using seaborn, but i keep getting an error, and i have no idea where i'm going wrong - i'm still very new to python and i'm not 100% sure what the errors mean or how best to fix them. Any help would be much appreciated. here is my code:
import pandas as pd
df = pd.DataFrame(
{
'labels': ['Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'Q10'],
'Participant 1': [1, 0, 0, 0, 2, 0, 2, 0, 2, 0],
'Participant 2': [1, 0, 0, 0, 2, 0, 2, 0, 0, 1],
'Participant 3': [0, 0, 0, 0, 0, 0, 2, 0, 0, 0],
'Participant 4': [0, 0, 0, 0, 2, 0, 2, 0, 0, 0],
'Participant 5': [1, 0, 1, 0, 2, 0, 2, 0, 0, 1],
'Participant 6': [0, 0, 0, 1, 2, 1, 2, 1, 2, 2],
'Participant 7': [0, 0, 0, 0, 2, 1, 2, 0, 0, 1],
'Participant 8': [0, 0, 0, 0, 2, 0, 2, 1, 0, 0],
'Participant 9': [0, 0, 0, 0, 2, 0, 2, 1, 2, 1],
'Participant 10': [0, 0, 0, 0, 2, 0, 2, 1, 0, 0]
},
).set_index('labels')
import seaborn as sns
import matplotlib.pylab as plt
ax = sns.heatmap(df)
plt.show()
but the image doesn't display and all i get is:
Out[155]: <AxesSubplot:ylabel='labels'>
It's probably something very obvious