[嗨,我想知道如何将图的y轴设置为数百万,因此与其显示5e7而不是显示5e7,它在相同位置会显示50。谢谢
您可以使用tick formatters显示如下所示的百万个数字
import numpy as np
import matplotlib.ticker as ticker
@ticker.FuncFormatter
def million_formatter(x, pos):
return "%.1f M" % (x/1E6)
x = np.arange(1E7,5E7,0.5E7)
y = x
fig, ax = plt.subplots()
ax.plot(x,y)
ax.xaxis.set_major_formatter(million_formatter)
ax.yaxis.set_major_formatter(million_formatter)
ax.set_xlabel('X in millions')
ax.set_ylabel('Y in millions')
plt.xticks(rotation='45')
plt.show
这导致