【问题标题】:Seaborn / Matplotlib: How to repress scientific notation in factorplot y-axisSeaborn / Matplotlib:如何抑制因子图 y 轴中的科学记数法
【发布时间】:2016-08-15 07:47:23
【问题描述】:

下面是我无法解决的这个问题的简单示例。

注意其他一些 Seaborn 绘图方法似乎有抑制指数形式的论据,但似乎不是factorplots。我尝试了一些 Matplotlib 解决方案,包括在 similar question 中建议的解决方案,但没有一个有效。这也不是this question 的欺骗。我非常频繁地使用因子图,理想情况下希望找到一个合适的解决方案而不是解决方法。

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") 

产生这个情节:

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

【问题讨论】:

  • 感谢您强调这种可能性 GWW - 我已经看到了这个问题并尝试了解决方案,但无济于事。
  • 你试过plt.ticklabel_format(style='plain', axis='y')吗?
  • @TonyBabarino - 从来没想过。完美运行。如果您将其发布为答案,我会接受。
  • 已发布,很高兴我能帮上忙,干杯!

标签: python matplotlib seaborn


【解决方案1】:

以下线路为我解决了这个问题(除了托尼的回答)

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

【讨论】:

  • 模块“seaborn”没有属性“plt”
【解决方案2】:

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

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

这里是documentation link

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-31
    • 2018-03-25
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 2018-10-13
    • 2013-07-18
    相关资源
    最近更新 更多