If I have the following data and Seaborn Heatmap:
import pandas as pd
data = pd.DataFrame({'x':(1,2,3,4),'y':(1,2,3,4),'z':(14,15,23,2)})
sns.heatmap(data.pivot_table(index='y', columns='x', values='z'))
How do I add a label to the colour bar?
If I have the following data and Seaborn Heatmap:
import pandas as pd
data = pd.DataFrame({'x':(1,2,3,4),'y':(1,2,3,4),'z':(14,15,23,2)})
sns.heatmap(data.pivot_table(index='y', columns='x', values='z'))
How do I add a label to the colour bar?
You can use:
You could set it afterwards after collecting it from an
ax
, or simply pass a label incbar_kws
like so.It is worth noting that
cbar_kws
can be handy for setting other attributes on the colorbar such as tick frequency or formatting.