How to add a label to Seaborn Heatmap color bar?

后端 未结 2 1301
猫巷女王i
猫巷女王i 2020-12-29 18:37

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(         


        
2条回答
  •  北海茫月
    2020-12-29 19:16

    You can use:

    ax = sns.heatmap(data.pivot_table(index='y', columns='x', values='z'))
    ax.collections[0].colorbar.set_label("Hello")
    

提交回复
热议问题