Seaborn Heatmap Colorbar Label as Percentage

前端 未结 4 987
醉话见心
醉话见心 2020-12-14 11:31

Given this heat map:

import numpy as np; np.random.seed(0)
import seaborn as sns; sns.set()
uniform_data = np.random.rand(10, 12)
ax = sns.heatmap(uniform_da         


        
4条回答
  •  悲哀的现实
    2020-12-14 12:04

    iterating on the solution of @mwaskom, without creating the colorbar yourself:

    import numpy as np
    import seaborn as sns
    data = np.random.rand(8, 12)
    ax = sns.heatmap(data, vmin=0, vmax=1)
    cbar = ax.collections[0].colorbar
    cbar.set_ticks([0, .2, .75, 1])
    cbar.set_ticklabels(['low', '20%', '75%', '100%'])
    

提交回复
热议问题