我可以通过在一行中将X和Y一起定义而不是每个轴的每一行来使这些行紧凑吗?谢谢,
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
#ax.yaxis.set_major_formatter(FixedOrderFormatter(-4))
ax.xaxis.major.formatter._useMathText = True
ax.xaxis.major.formatter._useOffset = False
ax.yaxis.major.formatter._useMathText = True
ax.yaxis.major.formatter._useOffset = False
答案 0 :(得分:0)
我想它可以稍微简化一下:
from matplotlib.ticker import ScalarFormatter
formatter = ScalarFormatter(useMathText=True)
formatter.set_useOffset(False)
f=plt.figure()
ax=f.add_subplot(1,1,1)
ax.plot(range(10), range(10), '.-')
#plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
#plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0))
#ax.yaxis.set_major_formatter(FixedOrderFormatter(-4))
#ax.xaxis.major.formatter._useMathText = True
#ax.xaxis.major.formatter._useOffset = False
#ax.yaxis.major.formatter._useMathText = True
#ax.yaxis.major.formatter._useOffset = False