问题报错: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, 2,3, 4,5, 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,)