import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['font.family']='SimHei' matplotlib.rcParams['font.sans-serif'] = ['SimHei'] labels = np.array(["进攻", "防守", "发球", "拦网", "传球","弹跳"]) dataLenth = 6 data = np.array([9.8, 9.5, 9.7, 9.5, 9.3, 9.0]) angles = np.linspace(0,2*np.pi,dataLenth,endpoint=False) #闭合 data = np.concatenate((data,[data[0]])) angles = np.concatenate((angles,[angles[0]])) labels=np.concatenate((labels,[labels[0]])) fig = plt.figure(facecolor="white") plt.subplot(111,polar=True) plt.plot(angles,data,'bo-',color ='g',linewidth=2) plt.fill(angles,data,facecolor='g',alpha=0.25) plt.thetagrids(angles*180/np.pi,labels) plt.figtext(0.52,0.95,'排球运动员-莱昂',ha='center') plt.grid(True) plt.show()要求多加入两位排球运动员的数据
时间: 2024-02-12 12:05:45 浏览: 140
import numpy as np import matplotlib.pyplot as plt import math
好的,可以将两位运动员的数据加入到原有的数据中,然后重新绘制雷达图。修改后的代码如下:
```
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family'] = 'SimHei'
matplotlib.rcParams['font.sans-serif'] = ['SimHei']
labels = np.array(["进攻", "防守", "发球", "拦网", "传球", "弹跳"])
dataLenth = 6
data = np.array([9.8, 9.5, 9.7, 9.5, 9.3, 9.0, 9.6, 9.4])
angles = np.linspace(0, 2*np.pi, dataLenth, endpoint=False)
data = np.concatenate((data, [data[0]]))
angles = np.concatenate((angles, [angles[0]]))
labels = np.concatenate((labels, [labels[0]]))
fig = plt.figure(facecolor="white")
plt.subplot(111, polar=True)
plt.plot(angles, data, 'bo-', color='g', linewidth=2)
plt.fill(angles, data, facecolor='g', alpha=0.25)
plt.thetagrids(angles*180/np.pi, labels)
plt.figtext(0.52, 0.95, '排球运动员-莱昂', ha='center')
plt.grid(True)
plt.show()
```
你可以按照这个格式,继续添加更多运动员的数据。
阅读全文