Python成绩雷达图

代码
1 import numpy as np 2 import matplotlib 3 import matplotlib.pyplot as plt 4 matplotlib.rcParams['font.family']='SimHei' 5 matplotlib.rcParams['font.sans-serif']='SimHei' 6 labels=np.array(['第一周','第二周','第三周','第四周','第五周','第六周','第七周']) 7 nAttr=7 8 data=np.array([0,8.7,10,8,9.7,8.1,0]) 9 angles=np.linspace(0,2*np.pi,nAttr,endpoint=False) 10 data=np.concatenate((data,[data[0]])) 11 angles=np.concatenate((angles,[angles[0]])) 12 fig=matplotlib.pyplot.figure(facecolor="white") 13 matplotlib.pyplot.figure(facecolor="white") 14 matplotlib.pyplot.subplot(111,polar=True) 15 matplotlib.pyplot.plot(angles,data,'bo-',color='g',linewidth=2) 16 matplotlib.pyplot.fill(angles,data,facecolor='g',alpha=0.25) 17 matplotlib.pyplot.thetagrids(angles*180/np.pi,labels) 18 matplotlib.pyplot.figtext(0.52,0.95,'SG.zhang成绩雷达图',ha='center') 19 matplotlib.pyplot.grid(True) 20 matplotlib.pyplot.savefig('dota_radar.JPG') 21 matplotlib.pyplot.show()

运行结果

猜你喜欢

转载自www.cnblogs.com/SGzhang/p/10743512.html