Note
Go to the end to download the full example code.
Possession retention after a restart
wa_setpieces.core.retention asks a broader question than the raw pass
outcome flag: did the team that took the set piece still have the ball
~8 seconds later, regardless of whether the very first pass found a
teammate. Not every plot needs a pitch underneath it – a simple bar chart
reads better for a team-by-team comparison.
from pathlib import Path
import matplotlib.pyplot as plt
from wa_setpieces import load_matches
from wa_setpieces.core.retention import retention_rate
try:
_here = Path(__file__).resolve().parent
except NameError:
_here = Path.cwd()
DATA = _here.parent / "tests" / "data" / "sample_match.json"
events = load_matches(DATA)