The scale factor is part of the standard ScalarFormatter
. If you don't want it use a different formatter, e.g. FormatStrFormatter
:
import matplotlib.pyplot as plt
plt.subplots()
plt.yticks([0,1.25*1e8,2.50*1e8])
plt.gca().yaxis.set_major_formatter(plt.matplotlib.ticker.FormatStrFormatter('%g'))
If you want 2.5e8
instead of 2.5e+08
you'll need to change the formatted string representation using a FuncFormatter
:
plt.gca().yaxis.set_major_formatter(plt.matplotlib.ticker.FuncFormatter(lambda x,_: f'{x:g}'.replace('+0','')))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…