ValueError: The number of FixedLocator locations (9), usually from a call to set_ticks, does not mat

问题报错:ValueError: The number of FixedLocator locations (9), usually from a call to set_ticks, does not match the number of ticklabels (8).

测试环境:

python

Windows 10

解决方法:

在是在构建雷达图时,少了某个标签的闭合步骤

如下例子:

labels = ['test1', 'test2', 'test3']
labels = np.concatenate((labels , [labels [0]]))  # 必须闭合
data = np.array([1, 23, 45, 6])
angles = np.linspace(0, 2 * np.pi,  len(labels)-1, endpoint=False)
data = np.concatenate((data, [data[0]]))  # 闭合
angles = np.concatenate((angles, [angles[0]]))  # 闭合

否则会报错,数据需要闭合,轴也要闭合,标签也要闭合,但是标签的闭合,因为标签 labels 多出了一个,会出现一个数据个数不一致的问题,所以需要 len(labels) -1,否则会报如下错误:

ValueError: x and y must have same first dimension, but have shapes (7,) and (6,) 

问题解决链接:

Python - ValueError: x and y must have same first dimension, but have shapes (7,) and (6,)


参考链接

1. python numpy 中linspace函数

2.【Python】np.linspace用法介绍

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值