代码:
from matplotlib import pyplot as plt
import random
x = range(0,120)
y = [random.randint(20,35) for i in range(120)]
#图片大小
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y)
#调整x轴的刻度
_x= list(x)[::10]
_xtick_labels= ["hello,{}".format(i) for i in _x]
plt.xticks(x,_xtick_labels)
plt.show
报错:
The number of FixedLocator locations (13), usually from a call to set_ticks, does not match the number of ticklabels (12).
解决办法:
plt.xticks(x,_xtick_labels) 这句x ,_xtick_labels长度不一致造成的
改成:plt.xticks(_x,_xtick_labels)