parent
659a61b1b8
commit
78d4a5bf8c
@ -0,0 +1,28 @@
|
||||
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()
|
Loading…
Reference in new issue