matplotlib - 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
你们能帮帮我吗。
谢谢!
解决方案
推荐阅读
- r - 在R中为蒙特卡罗模拟函数创建点距离分量
- javascript - 使用默认参数和 useEffect 防止函数组件出现无限循环
- swiftui - NSView 类中的初始化程序和 super.init() 出错
- c# - 将属性自动映射到从 ValueTuple 的第一个属性继承的对象
- c - if else 函数的 C 算法
- ios - swiftUI backButtonDisplayMode
- excel - 在列表中查找相关字符串的位置
- node.js - Sequelizenot 映射正确地属于许多
- python - 有没有办法替换列表中的随机单词?
- python - 如果我有来自一个函数的两个输出值,我可以将输出用作数组的参数(类型 int)吗?