python - 如何制作一个不是线性或对数的特定轴?

标签 python matplotlib plot axes

我想复制这个轴(见图),我的值范围是 1-10 - 这是什么格式,如何在 matplotlib 中实现?

enter image description here

最佳答案

import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import numpy as np

fig, ax = plt.subplots()
x = np.linspace(1, 11, 100)
y = np.sin(x)
ax.plot(x, y)
ax.set_xscale('log')
ax.xaxis.set_major_formatter(ticker.ScalarFormatter())
ax.xaxis.set_major_locator(ticker.FixedLocator([1, 3, 6, 10]))
ax.set_xlim(0, 11)
plt.show()

enter image description here

关于python - 如何制作一个不是线性或对数的特定轴?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16068883/

相关文章:

加法双向表 Tukey 图的 R 实现

python - 从深度嵌套的小部件访问 PySide PyQt MainWindow 或 Central Widget

python - 无法在 Python 中读取 JSON 文件

python - 维护 PIP 存储库

python - 从 Pandas 数据框制作多个饼图(每行一个)

matlab - 重置用于在 Matlab/Octave 中绘图的 ColorOrder 索引

python - 在 windows7 上使用 Python 2.7 将 CSV 转换为 Mysql

Python wav 绘图,该图未绘制

python - matplotlib 边框宽度

r - 使用 stat_summary 用观察次数注释绘图