Python 数据科学包_实例(球员能力图)

# coding=<utf-8>
import  numpy as np
import  matplotlib.pyplot as plt
from matplotlib.font_manager import *


plt.style.use('ggplot')
#解决中文显示的为框框
font =FontProperties(fname =r'C:\Windows\Fonts\simfang.ttf',size=12)

 #能力
ability_size = 6
ability_labels = [u'进攻',u'防守',u'盘带',u'速度',u'体力',u'射术']#转化为Unicode

#构造画布
ax1= plt.subplot(221,projection = 'polar')
ax2= plt.subplot(222,projection = 'polar')
ax3= plt.subplot(223,projection = 'polar')
ax4= plt.subplot(224,projection = 'polar')
 
#取消网格

ax1.grid(False)
ax2.grid(False)
ax3.grid(False)
ax4.grid(False)


#构造球员能力,随机生成的
player = {
    'M':np.random.randint(size=ability_size,low=60,high=90),
    'H':np.random.randint(size=ability_size,low=60,high=90),
    'P':np.random.randint(size=ability_size,low=60,high=90),
    'Q':np.random.randint(size=ability_size,low=60,high=90),
 }

#角度,最后一个和第一个重合
theta = np.linspace(0,2*np.pi,6,endpoint=False)
theta = np.append(theta,theta[0])


#绘制MX的图
player ['M'] = np.append(player['M'],player['M'][0])
ax1.plot(theta,player['M'],'r')
ax1.fill(theta,player['M'],'r',alpha =0.3 )
ax1.set_xticks(theta)#分成六等分
ax1.set_xticklabels(ability_labels,y = 0.01,fontproperties= font)#指定字体和y坐标
ax1.set_title(u'MX',fontproperties = font,color = 'r',size=20)
ax1.set_yticks([20,40,60,80,100])

#绘制HW的图
player ['H'] = np.append(player['H'],player['H'][0])
ax2.plot(theta,player['H'],'g')
ax2.fill(theta,player['H'],'g',alpha =0.3 )
ax2.set_xticks(theta)#分成六等分
ax2.set_xticklabels(ability_labels,y = 0.01,fontproperties= font)#指定字体和y坐标
ax2.set_title(u'HW',fontproperties = font,color = 'g',size=20)
ax2.set_yticks([20,40,60,80,100])

#绘制PK的图
player ['P'] = np.append(player['P'],player['P'][0])
ax3.plot(theta,player['P'],'#A020F0')
ax3.fill(theta,player['P'],'#A020F0',alpha =0.3 )
ax3.set_xticks(theta)#分成六等分
ax3.set_xticklabels(ability_labels,y = 0.01,fontproperties= font)#指定字体和y坐标
ax3.set_title(u'PK',position  = (0.5,1),fontproperties = font,color = '#A020F0',size=20)
ax3.set_yticks([20,40,60,80,100])
 
#绘制QH的图
player ['Q'] = np.append(player['Q'],player['Q'][0])
ax4.plot(theta,player['Q'],'y')
ax4.fill(theta,player['Q'],'y',alpha =0.3 )
ax4.set_xticks(theta)#分成六等分
ax4.set_xticklabels(ability_labels,y = 0.01,fontproperties= font)#指定字体和y坐标
ax4.set_title(u'QH',position  = (0.5,1),fontproperties = font,color = 'y',size=20,y=1)
ax4.set_yticks([20,40,60,80,100])

plt.show()

在这里插入图片描述

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wang_chao118

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

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值