【问题标题】:change scientific notation abbreviation of y axis units to a string将 y 轴单位的科学记数法缩写更改为字符串
【发布时间】:2018-05-15 02:01:47
【问题描述】:

首先我要道歉,因为我知道我没有正确地问这个问题(这就是为什么我找不到可能是一个简单的答案的原因)。

我有一张图

正如您在 y 轴上方看到的那样,它显示 1e11 表示单位为 1000 亿。我想将图表更改为 1000 亿而不是 1e11。

我不知道这样的符号叫什么。

需要明确的是,我并不是要求将整个 y 轴更改为数字值,就像其他问题一样,我只想将顶部 1e11 更改为对数学较少的人更具可读性。

ax.get_yaxis().get_major_formatter().set_scientific(False)

导致 出现不希望的结果

【问题讨论】:

标签: pandas matplotlib python-3.6


【解决方案1】:
import numpy as np
from matplotlib.ticker import FuncFormatter

def billions(x, pos):
    return '$%1.1fB' % (x*1e-9)

formatter = FuncFormatter(billions)

ax.yaxis.set_major_formatter(formatter)

位于https://matplotlib.org/examples/pylab_examples/custom_ticker1.html

产生

【讨论】:

  • 你打败了我。 :) +1
  • 不知道 matplotlib 有。 +1。
猜你喜欢
  • 1970-01-01
  • 2020-06-26
  • 1970-01-01
  • 2017-10-02
  • 1970-01-01
  • 1970-01-01
  • 2019-04-22
  • 1970-01-01
  • 2016-04-12
相关资源
最近更新 更多