So, I tried making a shot map in python using Statsbomb's free data, and when the map is generated, it only displays one shot and the other doesn't appear whilst the desired result is to have all the shots appear in the map.
Here's my code:
pitchLengthX=120
pitchWidthY=8
home_team_required ="Iceland Women's"
away_team_required ="France Women's"
pitch = Pitch()
fig, ax = pitch.draw(figsize=(120, 80))
for i,shott in shots.iterrows():
pitchLengthX=120
pitchWidthY=80
goal=shott['shot_outcome']=='Goal'
team_name=shott['team']
circleSize=2
x=shott['location'][0]
y=shott['location'][1]
if (team_name==home_team_required):
if goal:
shotCircle=plt.Circle((x,pitchWidthY-y),circleSize,color="red")
plt.text((x+1),pitchWidthY-y+1,shott['player'])
else:
shotCircle=plt.Circle((x,pitchWidthY-y),circleSize,color="red")
shotCircle.set_alpha(.2)
ax.add_patch(shotCircle)
elif (team_name==away_team_required):
if goal:
shotCircle=plt.Circle((x,pitchLengthX-x,y), circleSize,color="blue")
plt.text((pitchLengthX-x+1),shott['player'])
else:
shotCircle=plt.Circle((x,pitchLengthX-x,y), circleSize,color="blue")
shotCircle.set_alpha(.2)
ax.add_patch(shotCircle)
plt.text(5,75,away_team_required + ' shots')
plt.text(80,75,home_team_required + ' shots')
fig.set_size_inches(20, 14)
plt.show()
The output is shown on the picture attached here
