Python Seaborn 在热图中显示 3 位数字的科学记数法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29647749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 04:49:58  来源:igfitidea点击:

Seaborn showing scientific notation in heatmap for 3-digit numbers

pythonpandasmatplotlibseaborn

提问by cigrainger

I'm creating a heatmap from a pandas pivot_table as below:

我正在从熊猫数据透视表创建热图,如下所示:

table2 = pd.pivot_table(df,values='control',columns='Year',index='Region',aggfunc=np.sum)
sns.heatmap(table2,annot=True,cmap='Blues')

It creates a heat map as shown below. You can see the numbers are not huge (max 750), but it's showing them in scientific notation. If I view the table itself this is not the case. Any idea on how I could get it to show the numbers in plain notation?

它创建了一个热图,如下所示。您可以看到这些数字并不大(最多 750 个),但它以科学记数法显示它们。如果我查看表格本身,情况并非如此。关于如何让它以普通符号显示数字的任何想法?

Heatmap

热图

采纳答案by EdChum

According to the docs, the param fmt=.2gis being applied because you've set annot=Trueso you can modify the format being applied to:

根据docsfmt=.2g正在应用参数是因为您已经设置,annot=True因此您可以修改应用于的格式:

sns.heatmap(table2,annot=True,cmap='Blues', fmt='g')