You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.1 KiB
28 lines
1.1 KiB
3 years ago
|
import numpy as np
|
||
|
import matplotlib.pyplot as plt
|
||
|
courses = ['C++', ' 计算机网络', '高数', '大学英语', '数据结构',
|
||
|
'java', '离散数学', '线性代数']
|
||
|
scores = [69, 90, 77, 69, 76.8, 68, 63, 89]
|
||
|
dataLength = len(scores) # 数据长度
|
||
|
# angles数组把圆周等分为dataLength份
|
||
|
angles = np.linspace(0, # 数组第一个数据
|
||
|
2*np.pi, # 数组最后一个数据
|
||
|
dataLength, # 数组中数据数量
|
||
|
endpoint=False) # 不包含终点
|
||
|
scores.append(scores[0])
|
||
|
angles = np.append(angles, angles[0]) # 闭合
|
||
|
# 绘制雷达图
|
||
|
plt.polar(angles, # 设置角度
|
||
|
scores, # 设置各角度上的数据
|
||
|
'rv--', # 设置颜色、线型和端点符号
|
||
|
linewidth=1.8) # 设置线宽
|
||
|
# 设置角度网格标签
|
||
|
plt.thetagrids(angles[:8]*180/np.pi,
|
||
|
courses,
|
||
|
fontproperties='simhei')
|
||
|
# 填充雷达图内部
|
||
|
plt.fill(angles,
|
||
|
scores,
|
||
|
facecolor='b',
|
||
|
alpha=0.6)
|
||
|
plt.show()
|