matplotlib画图时报错The number of FixedLocator locations (120), usually from a call to set_ticks

代码:

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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值