简体   繁体   中英

Disabling scientific notation on a scale matplotlib

I'm trying to make a graph with non-scientific notation on y-scale. 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. Is there any chance to force it to be 1000000 rather than 0.1e7? Thank you in advance.

您可以禁用科学记数法

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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