Soccer Analytics with StatsBomb & xG
Pass maps, shot maps, heatmaps and pass networks from free professional event data — plus a real World Cup dataset.
Soccer's analytics revolution runs on event data, and StatsBomb gives a professional-grade slice of it away free. This course builds the four canonical match visualizations — pass map, xG shot map, player heatmap, team pass network — then closes on a real tournament: goals by stage at the 2026 World Cup, from a bundled snapshot of actual results.
An xG league table from Understat data rounds out the toolkit — the single most useful number for judging whether a team's results are sustainable.
What you'll be able to do
- Navigate StatsBomb event data and know what's in it
- Draw pass maps, shot maps and heatmaps on a properly scaled pitch
- Build a team pass network and read its structure
- Construct an xG table and argue from it
The bundle contains each part's finished script, the shared helpers, and the sample data they read, with a README listing the run order - the whole course works offline.
The syllabus
Pace: In order for the first two parts, then free order. The World Cup part is the payoff - a real tournament in your hands.
0 of 6 parts marked complete on this device.
Every part of this course is marked complete on this device. The capstone below is the victory lap - and the quiz will tell you if anything slipped.
- Build an xG League Table from Understat DataxG against the table: the sustainability check every result needs.
- Draw a Pass Map with mplsoccerEvent data made visible - your first professional-grade match graphic.
- Build a Match Shot Map with Expected GoalsChance quality on the pitch map, not just the scoreline.
- Draw a Player Heatmap from Event DataWhere a player actually operated, from raw event coordinates.
- Build a Team Pass NetworkTeam structure as a graph - who really connects the play.
- Group vs Knockout Scoring at a Live World Cup, with groupbyA live-tournament dataset, one groupby, a real finding.
Check yourself
Five questions, graded on the page, nothing recorded anywhere - pick an answer and the explanation appears.
1. Expected goals (xG) measures…
Each shot gets a probability from location, angle and situation. Summed, it says how many goals the chances 'should' produce on average.
2. A team running far ahead of its xG for several matches is…
Sustained overperformance of chance quality is mostly finishing variance, and it tends to fall back - which is why xG tables predict future results better than league tables.
3. In a pass network, node size and edge thickness typically encode…
The graph is built from passing events: who touched the ball, and who moved it to whom, how often.
4. StatsBomb open data is…
It's genuine pro-level event data released free for public use - the attribution requirement is the licence's main ask.
5. How does a team win 1-0 while 'losing' the xG battle?
Ninety minutes is a tiny sample. Good chances get missed and half-chances go in - which is exactly why xG and the scoreline diverge in single games.
Where next: Statistics for Sports Data · Sports Data Visualization.