import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
plt.style.use('dark_background')
ability_label=['Attack','Defence','Dribble','Speed','Strenth','Shoot']
ax1=plt.subplot(221,projection='polar')# 投影极坐标
ax2=plt.subplot(222,projection='polar')
ax3=plt.subplot(223,projection='polar')
ax4=plt.subplot(224,projection='polar')
ability_size=6
player={
'M':np.random.randint(size=ability_size,low=60,high=99),
'H':np.random.randint(size=ability_size,low=50,high=95),
'P':np.random.randint(size=ability_size,low=50,high=95),
'Q':np.random.randint(size=ability_size,low=50,high=95),
}
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'],'r')
ax1.fill(theta,player['M'],'r',alpha=0.5)
ax1.set_xticks(theta)
ax1.set_xticklabels(ability_label)
ax1.set_title('Messi',size=20)
player['P']=np.append(player['P'],player['P'][0])
ax2.plot(theta,player['P'],'g')
ax2.fill(theta,player['P'],'g',alpha=0.5)
ax2.set_xticks(theta)
ax2.set_xticklabels(ability_label)
ax2.set_title('Pique',size=20)
plt.show()
python数据科学基础day17-matplotlib球员能力图练习
最新推荐文章于 2022-10-29 19:31:43 发布