我有一张图片:
我希望在y轴上显示5x10^-5 4x10^-5
等形式,而不是0.00005 0.00004
。
目前我尝试过的方法是:
fig = plt.figure()
ax = fig.add_subplot(111)
y_formatter = matplotlib.ticker.ScalarFormatter(useOffset=True)
ax.yaxis.set_major_formatter(y_formatter)
ax.plot(m_plot,densities1,'-ro',label='0.0<z<0.5')
ax.plot(m_plot,densities2, '-bo',label='0.5<z<1.0')
ax.legend(loc='best',scatterpoints=1)
plt.legend()
plt.show()
这似乎不起作用。 刻度线文档页面似乎没有直接答案。
%2.2e
是什么意思? - user3397243%2.2e
用来选择字符串的格式。其中数字部分表示你想要保留的小数位数,字母'e'表示科学计数法。详细信息可以在这里找到。 - Ffisegydd