机器学习——科学数据包(六)

机器学习—Python数据可视化分析(matplotlib)

一、球员能力图

#_*_ coding:utf-8 _*_
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import  FontProperties #显示的定义所要使用的字体 _

plt.style.use('ggplot')

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

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

ax1=plt.subplot(221,projection='polar') #生成2行2列的第一个极坐标子图
ax2=plt.subplot(222,projection='polar')
ax3=plt.subplot(223,projection='polar')
ax4=plt.subplot(224,projection='polar')

#随机生成学员的能力值
player={
    'M':np.random.randint(size=ability_size,low=60,high=99),
    'H':np.random.randint(size=ability_size,low=60,high=99),
    'P':np.random.randint(size=ability_size,low=60,high=99),
    'Q':np.random.randint(size=ability_size,low=60,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]) #使M产生的数值形成首尾相接闭环的效果
ax1.plot(theta,player['M'],'r')#绘制首尾相接的图
ax1.fill(theta,player['M'],'r',alpha=0.3) #用红色填充
ax1.set_xticks(theta)#定义成6等分的ticks
ax1.set_xticklabels(ability_label,y=0.1,fontproperties=font)
ax1.set_title(u'梅西',fontproperties=font,color='r',size=20)

player['H']=np.append(player['H'],player['H'][0]) #使M产生的数值形成首尾相接闭环的效果
ax2.plot(theta,player['H'],'g')#绘制首尾相接的图
ax2.fill(theta,player['H'],'g',alpha=0.3) #用红色填充
ax2.set_xticks(theta)#定义成6等分的ticks
ax2.set_xticklabels(ability_label,y=0.1,fontproperties=font)
ax2.set_title(u'哈维',fontproperties=font,color='g',size=20)

player['P']=np.append(player['P'],player['P'][0]) #使M产生的数值形成首尾相接闭环的效果
ax3.plot(theta,player['P'],'b')#绘制首尾相接的图
ax3.fill(theta,player['P'],'b',alpha=0.3) #用红色填充
ax3.set_xticks(theta)#定义成6等分的ticks
ax3.set_xticklabels(ability_label,y=0.1,fontproperties=font)
ax3.set_title(u'皮克',fontproperties=font,color='b',size=20)

player['Q']=np.append(player['Q'],player['Q'][0]) #使M产生的数值形成首尾相接闭环的效果
ax4.plot(theta,player['Q'],'y')#绘制首尾相接的图
ax4.fill(theta,player['Q'],'y',alpha=0.3) #用红色填充
ax4.set_xticks(theta)#定义成6等分的ticks
ax4.set_xticklabels(ability_label,y=0.1,fontproperties=font)
ax4.set_title(u'切赫',fontproperties=font,color='y',size=20)


plt.show()

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值