Rating spread: beeswarm

plot_rating_benchmark() ranks players as horizontal bars – great for “who’s best,” but it can’t show whether the squad is one tight cluster around average or has a real standout and a long tail. plot_rating_beeswarm() plots the same 0-100 rating as one dot per player instead, spread apart just enough to stay readable, so the shape of the distribution is visible at a glance.

As with every other single-match example in this gallery, ratings here are z-scored against a sample of six players – see wa_setpieces.core.rating’s module docstring on why a real rating needs a full season/competition behind it, not one match.

from pathlib import Path

from wa_setpieces import load_matches
from wa_setpieces.core.rating import player_rating
from wa_setpieces.core.xt import XTModel
from wa_setpieces.viz.plots import plot_rating_beeswarm

try:
    _here = Path(__file__).resolve().parent
except NameError:
    _here = Path.cwd()
DATA = _here.parent / "tests" / "data" / "sample_match.json"

events = load_matches(DATA)
model = XTModel.fit(events, x_bins=8, y_bins=6)
rated = player_rating(events, "corner", model, min_deliveries=1, min_shots=1)
rated[["playerName", "contestantId", "rating"]]
playerName contestantId rating
0 S. Vasquez f2yd0yzt0om6qhks9gbowu1d6 60.6
1 V. Burgoa f2yd0yzt0om6qhks9gbowu1d6 48.2
2 P. Velasco f2yd0yzt0om6qhks9gbowu1d6 48.2
3 D. Armas f2yd0yzt0om6qhks9gbowu1d6 48.2
4 R. Jaramillo f2yd0yzt0om6qhks9gbowu1d6 48.2
5 A. Tobar cxb4hqite921i36gwrezdts7c 46.6


fig, ax = plot_rating_beeswarm(rated, title="Corner rating spread")
plot 23 rating beeswarm

Gallery generated by Sphinx-Gallery