Pass maps are a powerful visualization tool in football analytics, helping analysts and coaches understand passing patterns, player connectivity, and team dynamics. Using StatsBomb Open Data, we can generate detailed pass maps that reveal strategic insights about a team’s playstyle and individual player tendencies.
This guide will introduce StatsBomb’s Open Data, how to access it, and how to create pass maps using Python and visualization tools like Matplotlib and Seaborn.
Interactive Data Filtering & Visualization
StatsBomb data can be analyzed using Python. Below is a guide on setting up the StatsBomb Python API and visualizing pass maps.
Creating a Pass Map
A pass map visualizes successful passes made by a player or team in a given match. Here’s an example using Python:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from statsbombpy import sb
# Load event data for a specific match
match_id = 3795220
events = sb.events(match_id=match_id)
# Filter passes
passes = events[events['type'] == 'Pass']
# Plot pass map
fig, ax = plt.subplots(figsize=(10, 6))
plt.xlim(0, 120)
plt.ylim(0, 80)
# Plot passes
for _, row in passes.iterrows():
plt.plot([row['location'][0], row['pass_end_location'][0]],
[row['location'][1], row['pass_end_location'][1]],
color='blue', alpha=0.5, lw=2)
plt.title("Pass Map for Match {}".format(match_id))
plt.show()
Advanced Visualization: Pass Maps by Player
Using Seaborn, we can create individual pass maps for specific players.
player_name = "Lionel Messi"
player_passes = passes[passes["player"] == player_name]
fig, ax = plt.subplots(figsize=(10, 6))
sns.scatterplot(x=player_passes["location"].apply(lambda x: x[0]),
y=player_passes["location"].apply(lambda x: x[1]),
color="red", s=100, label=player_name)
plt.title(f"Pass Map for {player_name}")
plt.show()
360 Data: Adding Player Positioning
StatsBomb also provides 360 freeze frame data, which includes the locations of players at key moments.
frames = sb.frames(match_id=3795220)
# Merge event data with frame data
pass_frames = frames[frames['type'] == 'Pass']
pass_frames = pass_frames.merge(passes, on='id')
# Visualize pass map with player positions
fig, ax = plt.subplots(figsize=(10, 6))
sns.scatterplot(x=pass_frames["location"].apply(lambda x: x[0]),
y=pass_frames["location"].apply(lambda x: x[1]),
color="green", label="Player Positions")
plt.title("Pass Map with Player Positions")
plt.show()
Resources & Further Reading
• StatsBomb Open Data: GitHub Repo
• StatsBombPy API: Python Library
• Football Analytics Guide: Getting Started with Football Analytics