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

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:
Matplotlib,控制x,y轴坐标标记步长_第1张图片



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

你可能感兴趣的:(python)