how to understand Seaborn's heatmap annotation format?

后端 未结 3 1641
忘了有多久
忘了有多久 2021-02-15 17:12

I am looking for a way to show \"0.0045\" as \"0.45%\" on seaboarn\'s heatmap by specifying the fmt keyword:

sns.heatmap(data, annot=Tr         


        
3条回答
  •  野性不改
    2021-02-15 17:30

    You can use .2% as the fmt to have your annotations displayed as percentages with 2 decimal places. Following is a minimum complete example. I have divided by 100 to have numbers in the range you are interested in


    import numpy as np; np.random.seed(0)
    import seaborn as sns; sns.set()
    uniform_data = np.random.rand(6, 6)/100
    ax = sns.heatmap(uniform_data,annot=True, fmt=".2%")
    

提交回复
热议问题