gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 21:24:21 27 4
gpt4 key购买 nike

我想复制这个轴(见图),我的值范围是 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com