首页 > 解决方案 > matplotlib 科学计数法整数 1e3

问题描述

如何用整数棒和科学记数法 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

你们能帮帮我吗。

谢谢!

标签: matplotlib

解决方案


推荐阅读