【问题标题】:How do I convert axis from scientific notation to standard numbers? [duplicate]如何将轴从科学计数法转换为标准数字? [复制]
【发布时间】:2021-01-08 10:26:37
【问题描述】:

我正在尝试绘制一些房价数据,所以想象一下在 100,000 - 300,000 范围内,但我的 Y 轴一直默认为科学计数法。

reading.plot(kind='scatter', x='Transaction Date',y='Price Paid', alpha=0.1, c='green', ylim=(0,2000000))

我应该添加一个额外的变量吗?

提前致谢!

丰富

【问题讨论】:

标签: python


【解决方案1】:

试试这个:

import matplotlib.pyplot as plt
fig, ax =  plt.subplots()
reading.plot(kind='scatter', x='Transaction Date',y='Price Paid', alpha=0.1, c='green', ylim=(0,2000000), ax=ax)
ax.ticklabel_format(style='plain')
plt.show()

【讨论】:

  • 谢谢 - 刚刚试了一下,奇怪的是得到了这个错误? AttributeError: 此方法仅适用于 ScalarFormatter 这对您来说意味着什么吗?再次感谢!
  • 你可以尝试使用 plt.ticklabel_format(style='plain', axis='y'),而不是 ax.ticklabel_format(style='plain') 我不知道确切的原因您遇到的错误(因为我无法在示例数据上重现错误)
  • 也看看这个问题,它提到了你得到的同样的错误:stackoverflow.com/questions/46735745/…>
  • plt.ticklabel_format(style='plain', axis='y') 工作!太感谢了!这样做有什么具体原因吗?
猜你喜欢
  • 2012-06-22
  • 1970-01-01
  • 1970-01-01
  • 2019-07-09
  • 2015-08-19
  • 2015-12-27
  • 1970-01-01
  • 2016-04-12
  • 2016-08-17
相关资源
最近更新 更多