Data Visualization

Seaborn Heatmap

Simple example with a colormap with light colors on small values and black colors on high values:

grouped = df.groupby(['column1', 'column2']).size().unstack()
h = sns.heatmap(grouped, cmap='bone_r')

Show values of each group:

grouped = df.groupby(['column1', 'column2']).size().unstack()
h = sns.heatmap(grouped, annot=True)

Changing colorbar limits:

grouped = df.groupby(['column1', 'column2']).size().unstack()
h = sns.heatmap(grouped, vmin=0, vmax=100)

Change annotation fontsize:

grouped = df.groupby(['column1', 'column2']).size().unstack()
h = sns.heatmap(grouped, annot=True, annot_kws={"size": 12})

Full example:

grouped = df.groupby(['column1', 'column2']).size().unstack()
h = sns.heatmap(grouped, cmap='bone_r', annot=True, 
                annot_kws={"size": 12}, vmin=0, vmax=100)

Cheers!
Letícia

Comments