Seaborn/Matplotlib:如何在因子图y轴上抑制科学计数法 [英] Seaborn / Matplotlib: How to repress scientific notation in factorplot y-axis

查看:103
本文介绍了Seaborn/Matplotlib:如何在因子图y轴上抑制科学计数法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我无法解决的简单示例.

注意其他一些 Seaborn 绘图方法似乎有理由抑制指数形式,但似乎不是 factorplots.我尝试了一些 Matplotlib 解决方案,包括在这个

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

解决方案

看起来下面这行代码解决了这个问题:

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

这是文档链接.

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

N.B. 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.

这篇关于Seaborn/Matplotlib:如何在因子图y轴上抑制科学计数法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆