how to understand Seaborn's heatmap annotation format?

后端 未结 3 1727
忘了有多久
忘了有多久 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条回答
  •  萌比男神i
    2021-02-15 17:39

    There isn't a clear and quick answer to this at the top of search engine results so I provide simple examples here:

    .1e = scientific notation with 1 decimal point (standard form)

    .2f = 2 decimal places

    .3g = 3 significant figures

    .4% = percentage with 4 decimal places

    A more detailed explanation on the python string formatter can be found here: https://docs.python.org/3/library/string.html?highlight=string#formatspec (scroll down to table with e, E, f, F, etc. in the Type column)

提交回复
热议问题