【问题标题】:Disabling scientific notation on a scale matplotlib在 matplotlib 上禁用科学记数法
【发布时间】:2019-04-07 07:20:04
【问题描述】:

我正在尝试在 y 尺度上使用非科学记数法制作图表。我的代码如下所示:

fig = mpl.figure(figsize=(10, 6))
ax = fig.add_subplot(111)
ax.semilogy(x,(y-0.9*best_vals[0]),'--',color = 'gray', lw = 1,fillstyle = 'none', label = 'experiment')
ax.semilogy(x[start:],(y_fit-0.9*best_vals[0]),'r-', label = '4-exponential fit')

ax.set_xlim(0,5000)
ax.set_ylim(1e2,1e6)
ax.yaxis.set_major_formatter(ScalarFormatter())

如果 y 刻度的上限设置为 1e5,则 y 刻度为 100、1000、10000、100000 时看起来非常好。但是当我尝试将其设置为 1e6 时,y 符号会更改为科学,上限为 0.1e7。有没有机会强制它为 1000000 而不是 0.1e7?提前谢谢你。

【问题讨论】:

    标签: python matplotlib scale


    【解决方案1】:

    您可以使用

    禁用科学记数法
    ax.get_yaxis().get_major_formatter().set_scientific(False)
    

    【讨论】:

      猜你喜欢
      • 2021-05-01
      • 2017-09-05
      • 1970-01-01
      • 2014-08-23
      • 2018-09-19
      • 1970-01-01
      • 2018-07-09
      • 2018-10-13
      • 2018-03-25
      相关资源
      最近更新 更多