-
Notifications
You must be signed in to change notification settings - Fork 108
/
2Answers_PlotThePasses.py
29 lines (25 loc) · 884 Bytes
/
2Answers_PlotThePasses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 6 21:26:30 2020
@author: davsu428
"""
#Find the passes
passes = df.loc[df['type_name'] == 'Pass'].set_index('id')
#Draw the pitch
(fig,ax) = createPitch(pitchLengthX,pitchWidthY,'yards','gray')
for i,thepass in passes.iterrows():
#if thepass['team_name']==away_team_required: #
if thepass['player_name']=='Lucy Bronze':
x=thepass['location'][0]
y=thepass['location'][1]
passCircle=plt.Circle((x,pitchWidthY-y),2,color="blue")
passCircle.set_alpha(.2)
ax.add_patch(passCircle)
dx=thepass['pass_end_location'][0]-x
dy=thepass['pass_end_location'][1]-y
passArrow=plt.Arrow(x,pitchWidthY-y,dx,-dy,width=3,color="blue")
ax.add_patch(passArrow)
fig.set_size_inches(10, 7)
fig.savefig('Output/passes.pdf', dpi=100)
plt.show()