Seaborn / Matplotlib:如何在事实y轴上抑制科学记数法

时间:2016-04-21 21:38:19

标签: python matplotlib seaborn

以下简单示例解决了我无法解决的问题。

N.B。其他一些Seaborn绘图方法似乎有压制指数形式的论据,但似乎不是factorplots。我尝试了一些Matplotlib解决方案,包括这个similar question中提出的解决方案,但都没有。这也不是this question的欺骗。我经常使用factorplots,理想情况下想找到一个合适的解决方案,而不是一个变通方法。

data = {'reports': [4, 24, 31, 2, 3],'coverage': [35050800, 54899767, 57890789, 62890798, 70897871]}
df = pd.DataFrame(data)
df

生成此数据框:

    coverage    reports
0   35050800    4
1   54899767    24
2   57890789    31
3   62890798    2
4   70897871    3

然后是这个Seaborn代码:

sns.factorplot(y="coverage", x="reports", kind='bar', data=df, label="Total") 

制作此情节:

enter image description here

有没有办法让y轴根据coverage值显示适当的数字刻度?

2 个答案:

答案 0 :(得分:5)

It looks like the following line solves the issue:

plt.ticklabel_format(style='plain', axis='y')

Here is the documentation link.

答案 1 :(得分:3)

以下一行解决了我的问题(除了Tony的回答)

sns.plt.ticklabel_format(style='plain', axis='y',useOffset=False)