2020-10-27实战案例

Python学习

实战案例

# encoding:utf-8

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

font=FontProperties(fname=r'c:\windows\fonts\simsun.ttc',size=12)

plt.style.use('ggplot')#美化样式

ablity_size=6
ability_laber=['进攻','防守','盘带','速度','体力','射术']

ax1=plt.subplot(221,projection='polar')#生成子图
ax2=plt.subplot(222,projection='polar')
ax3=plt.subplot(223,projection='polar')
ax4=plt.subplot(224,projection='polar')

player={
'M':np.random.randint(size=ablity_size,low=66,high=99),
'H':np.random.randint(size=ablity_size,low=66,high=99),
'P':np.random.randint(size=ablity_size,low=66,high=99),
'Q':np.random.randint(size=ablity_size,low=66,high=99)
}
theta=np.linspace(0,2*np.pi,6,endpoint=False)
theta=np.append(theta,theta[0])
player['M']=np.append(player['M'],player['M'][0])

ax1.plot(theta,player['M'],player['M'][0])
ax1.fill(theta,player['M'],'r',alpha=0.3)
#把laber去掉换成能力
ax1.set_xticks(theta)
ax1.set_xticklabels(ability_laber,y=0.01,fontproperties=font)
ax1.set_title('梅西',fontproperties=font,size=20,color='r')
ax1.set_yticks([20,40,60,80,100])#强制定义数字

player['H']=np.append(player['H'],player['H'][0])

ax2.plot(theta,player['H'],player['H'][0],'g')
ax2.fill(theta,player['H'],'g',alpha=0.3)
#把laber去掉换成能力
ax2.set_xticks(theta)
ax2.set_xticklabels(ability_laber,y=0.01,fontproperties=font)
ax2.set_title('哈维',fontproperties=font,size=20,color='g')
ax2.set_yticks([20,40,60,80,100])#强制定义数字

player['P']=np.append(player['P'],player['P'][0])

ax3.plot(theta,player['P'],player['P'][0])
ax3.fill(theta,player['P'],'b',alpha=0.3)
#把laber去掉换成能力
ax3.set_xticks(theta)
ax3.set_xticklabels(ability_laber,y=0.01,fontproperties=font)
ax3.set_title('皮克',position=(0.5,1),fontproperties=font,size=20,color='b')
ax3.set_yticks([20,40,60,80,100])#强制定义数字
player['Q']=np.append(player['Q'],player['Q'][0])

ax4.plot(theta,player['Q'],player['Q'][0])
ax4.fill(theta,player['Q'],'y',alpha=0.3)
#把laber去掉换成能力
ax4.set_xticks(theta)
ax4.set_xticklabels(ability_laber,y=0.01,fontproperties=font)
ax4.set_title('切赫',position=(0.5,1),fontproperties=font,size=20,color='y')
ax4.set_yticks([20,40,60,80,100])#强制定义数字

plt.show()

• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 打赏

打赏

Mylove丶father

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 举报
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文