gpt4 book ai didi

python - 如何在固定位置上设置刻度,matplotlib

转载 作者:IT老高 更新时间:2023-10-28 22:14:10 26 4
gpt4 key购买 nike

谁能帮助我使用 matplotlib 将刻度设置在固定位置?正如本教程所述,我已尝试使用 FixedPosition:

ax = pl.gca()
ax.xaxis.set_major_locator(eval(locator))

http://scipy-lectures.github.io/intro/matplotlib/matplotlib.html#figures-subplots-axes-and-ticks

但是当我尝试运行时,它告诉我 set_major_locator 方法不存在。

一个简单的例子会很有用。

谢谢。

最佳答案

只需使用 ax.set_xticks(positions)ax.set_yticks(positions)

例如:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.set_xticks([0.15, 0.68, 0.97])
ax.set_yticks([0.2, 0.55, 0.76])
plt.show()

enter image description here

关于python - 如何在固定位置上设置刻度,matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17129947/

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