简体   繁体   中英

Seaborn / Matplotlib: How to repress scientific notation in factorplot y-axis

Simple example below for this issue which I just can't solve.

NB Some other Seaborn plotting methods seems to have arguments to repress the exponential form but seemingly not factorplots . I tried some Matplotlib solutions including those suggested in this similar question but none work. Also this is not a dupe of this question . I use factorplots very frequently and ideally want to find a proper solution as opposed to a workaround.

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

Produces this dataframe:

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

And then this Seaborn code:

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

Produces this plot:

在此输入图像描述

Is there a way to get the y axis to display an appropriate numeric scale based on the coverage values?

It looks like the following line solves the issue:

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

Here is the documentation link .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM