我想更改情节的标签
fig=figure(figsize=(7.5,7.5))
labels = [0,0.00001,0.0001,0.001,0.01,0.1,1]
plt.xscale('log')
plt.xlim(10^-6,1.1)
plt.xticks(y, labels)
但我希望标签格式为10^-5, 10^-4, 10^-3, 10^-2, 10^-1, 1
,而不是1e-05, 0.0001, 0,001, 0,01, 0.1, 1
答案 0 :(得分:0)
您需要FormatStrFormatter('%.2e')
由于您没有发布整个脚本,我只能向您展示一个示例:
如果我们从matplolib
获取此演示只需将majorFormatter = FormatStrFormatter('%d')
更改为我之前展示的内容,您就会看到
您只需将主轴重新格式化为:
ax.xaxis.set_major_formatter(FormatStrFormatter('%.2e'))