import numpy as np
from matplotlib import pyplot as plt
x = np.arange(0, 10)
fig = plt.figure()
plt.plot(x, color='black', linestyle='dashed', label='x', marker='*')
plt.legend()
# 更改横坐标刻度
# plt.xticks([0,1,2,3,4,5,6,7,8,9], [0, 10, 20, 30, 40, 50, 60, 70, 80, 1000])
plt.xticks([5], [20000])
plt.show()
限制坐标轴
import numpy as np
from matplotlib import pyplot as plt
x = np.arange(0, 10)
fig = plt.figure()
plt.plot(x, color='black', linestyle='dashed', label='x', marker='*')
plt.legend()
# 限制坐标轴
plt.xlim([0, 5])
plt.show()