fig, axes = plt.subplots(3,4,figsize=(12,12))
fig.set_facecolor('#3b3b38')
axes.flat[-1].set_visible(False)
pitch = Pitch(pitch_type='statsbomb', orientation='vertical',
pitch_color='#3b3b38', line_color='#c7d5cc', figsize=(13, 8),
constrained_layout=False, tight_layout=True)
for i,ax in enumerate(fig.axes):
try:
ax.set_facecolor('#3b3b38')
pitch.draw(ax=ax)
df = df1[(df1.playerId == starters[i])]
df = df[(np.abs(stats.zscore(df[['x','y']])) < .5)]
points = df[['y','x']].values
hull = ConvexHull(df[['x','y']])
for simplex in hull.simplices:
ax.plot(points[simplex, 0], points[simplex, 1], '#A50044',lw=3)
ax.fill(points[hull.vertices,0], points[hull.vertices,1], c='white', alpha=0.1)
ax.set_ylabel(ylabel=' ')
ax.set_title(label=starters[i],c='white',va='center',ha='center',fontsize=18,fontfamily='Andale Mono')
except:
pass
s = f'Barcelona <Pass Territories> vs Real Betis'
fig_text(s=s,
x=.175,y=.9,
fontfamily='Andale Mono',
highlight_weights=['bold'],
fontsize=24,
color='white',
highlight_colors=['#A50044'],
zorder=1
)
fig.text(.15,.1,'@mckayjohns / Twitter',fontstyle='italic',fontsize=12,fontfamily='Andale Mono',color='w')
fig.text(.15,.08,'territories indications of starting pass locations with outliers removed',fontstyle='italic',fontsize=12,fontfamily='Andale Mono',color='w')
fig.savefig('convexgrid.png',facecolor='#3b3b38',dpi=500,bbox_inches='tight')