简体   繁体   English

在比例 matplotlib 上禁用科学记数法

[英]Disabling scientific notation on a scale matplotlib

I'm trying to make a graph with non-scientific notation on y-scale.我正在尝试在 y 尺度上用非科学符号制作一个图表。 My code looks like this:我的代码如下所示:

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

If the upper limit of y scale is set up to 1e5 it look perfectly fine with y ticks 100, 1000, 10000, 100000. But when I try to make it 1e6 y notation changes to scientific with upper limit 0.1e7.如果 y 刻度的上限设置为 1e5,则 y 刻度为 100、1000、10000、100000 时看起来非常好。但是当我尝试将其设为 1e6 时,y 符号更改为科学,上限为 0.1e7。 Is there any chance to force it to be 1000000 rather than 0.1e7?有没有机会强制它是 1000000 而不是 0.1e7? Thank you in advance.先感谢您。

您可以禁用科学记数法

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM