如何用整数棒和科学记数法 1e3 绘制 yaxis。
from matplotlib import pyplot as plt
import numpy as np
fig, ax = plt.subplots(1, 1)
x = np.linspace(0, 5, 11)
y = x**4
ax.plot(x, x ** 2, x, np.exp(x))
ax.set_title("scientific notation")
ax.set_yticks([100, 5000, 10000, 15000])
from matplotlib import ticker
formatter = ticker.ScalarFormatter(useMathText=True)
formatter.set_scientific(True)
formatter.set_powerlimits((-1, 1))
ax.yaxis.set_major_formatter(formatter)
plt.show()
此代码显示 1.50 x 10^4, 现在我想显示 15 x 10^3
你们能帮我吗。
谢谢!