class matplotlib.ticker.ScalarFormatter(useOffset=True,
useMathText=False, useLocale=None) Bases: matplotlib.ticker.Formatter
Tick location is a plain old number. If useOffset==True and the data
range is much smaller than the data average, then an offset will be
determined such that the tick labels are meaningful. Scientific
notation is used for data < 10^-n or data >= 10^m, where n and m are
the power limits set using set_powerlimits((n,m)). The defaults for
these are controlled by the axes.formatter.limits rc parameter.
你的技巧是:xfmt = ScalarFormatter()
xfmt.set_powerlimits((-3,3)) # Or whatever your limits are . . .
{{ Make your plot }}
gca().xaxis.set_major_formatter(xfmt)
要获取以x10^5格式显示的指数,请使用useMathText=True实例化ScalarFormatter。
您还可以使用:xfmt.set_useOffset(10000)
要得到这样的结果: