python - 默认情况下对 Python 绘图使用科学记数法
问题描述
简单的问题:如何让 Python 默认在其绘图中使用科学记数法?从 SO 上的各种帖子中,我可以写一些类似的东西
from numpy import linspace
import matplotlib.pyplot as plt
plt.figure()
plt.plot(linspace(1e6,2e6),linspace(1e6,1e7))
plt.figure()
plt.plot(linspace(8e6,9e6),linspace(2e6,2.5e7))
plt.ticklabel_format(style='sci', axis='both', scilimits=(-2,2))
plt.show()
但ticklabel_format
仅作用于 matplotlib 生成的最后一个图。(如果plt.ticklabel_format()
放在代码的开头,我还会得到一个显示 x、y 轴的空白图。)
解决方案
您可以通过编辑“rc”文件来修改 matplotlib 的默认行为。请参阅自定义 matplotlib。
在您的情况下,您似乎可以调整项目:
axes.formatter.limits : -2, 2 # use scientific notation if log10
# of the axis range is smaller than the
# first or larger than the second
推荐阅读
- mysql - SQL查询按两个不同的列过滤结果
- html - 如何将谷歌表格中的特定可编辑单元格嵌入到网站中
- reactjs - 使用 Typescript 在 React 中创建自定义钩子而不传递道具
- coinbase-api - Coinbase API - 无效签名
- python-3.x - 从函数中获取多个变量值或信息的最佳方法
- jquery - MediaWiki API 在 Android 9 (api 28) 之后无法工作
- python-3.x - 区分 IPFS 链接和普通链接
- omnet++ - 如何在 .ned 文件中声明参数向量
- delphi - 在直线上绘制一个点
- python - 如何在python中自动创建父类的所有子对象?