Matplotlib,控制x,y轴坐标标记步长

2023-11-18

Code Example

import matplotlib.pyplot as plt

xs = [0, 5, 9, 10, 15]
ys = [0, 1, 2, 3, 4]
plt.plot(xs, ys)
plt.xticks([x for x in range(max(xs) + 1) if x % 2 == 0])  # x标记step设置为2
plt.yticks([y for y in range(max(ys) + 1)])  # y标记step设置为1
plt.show()

Result:
result



Ref
http://stackoverflow.com/questions/12608788/changing-the-tick-frequency-on-x-or-y-axis-in-matplotlib

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Matplotlib,控制x,y轴坐标标记步长 的相关文章

随机推荐