Appendix K β Visualization Gallery
Every chart in this book answers a cricket question. This gallery collects every kind of chart the book draws β 29 of them β and for each one gives you:
- the question it answers and when to reach for it;
- where the code lives β a function in the Crease chart module,
project/crease/charts.py(built in Chapter 7), or the chapter script that draws the book's version; - a minimal runnable call;
- a fresh rendering on real data, drawn for this appendix by
appendices/code/k_gallery.py; - a π described-figure line for readers who cannot see the image;
- design notes β the house conventions the chart follows, and why;
- where it appears in the chapters.
Match charts are drawn for the book's Anchor A: South Africa v Sri Lanka, 3rd T20I, Newlands, Cape Town, 25 January 2017 (Cricsheet match id 936157). South Africa made 169/5; Sri Lanka were 116/2 after 15 overs, lost two wickets for two runs in Imran Tahir's 16th over, and still won by five wickets with a ball to spare.
π Fan Track: browse the pictures and the "question" lines; skip the code. Every chart's takeaway is in its π line.
π Analyst Track: use the "minimal call" blocks as copy-and-paste starting points, and the design notes as a checklist before you publish a chart.
How to run the gallery
All 29 figures come from one script, which finishes in under a minute on a laptop once the data has been built:
python appendices/code/k_gallery.py
Its full printed output β the numbers behind every figure quoted below β is saved in appendices/code/k_output.txt. Every minimal call in this appendix assumes this setup block (the same header every chapter script uses):
import sys
from pathlib import Path
BOOK = Path(r"C:\books\cricket-analytics") # wherever your copy of the book lives
sys.path.insert(0, str(BOOK / "toolkit"))
sys.path.insert(0, str(BOOK / "project"))
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from cricdata import load_deliveries, load_matches, batting_summary, bowling_summary
from crease import charts
charts.style() # the book's quiet house style
t20i = load_deliveries("t20s_male")
games = load_matches("t20s_male")
m = charts.match_balls(t20i, "936157") # Anchor A, super overs removed, in order
The house style in one page
These conventions come from Chapter 7 and are built into crease.charts, so you get them for free when you use the module. When you draw something by hand, follow them.
| Convention | Rule | Why |
|---|---|---|
| Colour by job, not by rank | Team batting first blue (#1f77b4); team batting second orange (#ff7f0e) β charts.TEAM_COLOURS. Dots grey, boundaries orange squares, wickets red with an "X" marker β charts.OUTCOME_COLOURS / OUTCOME_MARKERS. |
The reader learns the code once and it holds in every chart in the book. The "X" means colour is never the only cue. |
| Comparison palette | Up to four series on one chart use the OkabeβIto set charts.COMPARE (#0072B2, #E69F00, #009E73, #CC79A7) and vary line style (COMPARE_STYLES) or marker (COMPARE_MARKERS). More than four: facet into small multiples. |
tab10's green and orange nearly merge under protanopia; OkabeβIto was designed for colour-vision deficiency. Identity is never carried by colour alone. |
| Never red-green alone | No chart uses red v green as its only contrast. Diverging heat maps use blueβred (RdBu_r). |
About one man in twelve has some redβgreen colour-vision deficiency. |
| One y-axis | No dual-axis charts. Two units, two charts. | A second scale lets the designer make any two lines appear to move together. |
| Overs are 1-based | Over 1 is the first over, in labels and in code. | It is how cricket counts. |
| Wagon wheels | Seen from above, batter at the centre, straight down the ground up the page; a right-hander's off side on the right, a left-hander's on the left. | Matches the broadcast convention, and keeps the batter's off side on the same side as the batter's off-side arm. |
| Pitch maps and beehives | Viewed from the bowler's end: the batter's stumps at the top of a pitch map; a right-hander's off side on the LEFT. | That is the view the bowler β and the broadcast pitch-map graphic β has. |
| Simulated data says so | Any chart drawn from the simulated tracking layer carries "simulated tracking layer β real outcomes, simulated locations" (charts.SIM_CAPTION) in its title or caption, and is flagged π§ͺ in the text. |
Hawk-Eye-style locations are not public. The outcomes are real; the locations are not, and nothing they show is a fact about a real player. |
| Numbers in heat-map cells; "n/a" for missing | Every heat-map cell prints its value; missing or suppressed cells are flat grey with "n/a". | Colour is the least accurate encoding (Cleveland & McGill); a missing cell must never look like an average one. |
| Annotate sparingly | One or two callouts that carry the story ("Tahir: 2 runs, 2 wickets"), not a label on every bar. | The reader's eye goes to the annotation first β spend it on the point. |
| Size and resolution | Saved at dpi 110, width β€ 10 inches, white background, via charts.save(fig, path). |
Readable on a phone and in print; consistent file sizes. |
β οΈ Common pitfall β forgetting the sample size. A strike rate on a chart without its balls is half a fact. Most charts in this gallery carry the sample in the title, the legend or the axis label ("58 batters with 1,500+ balls", "Four (10)"). Do the same.
Index: the 23 functions of crease.charts
| Function | What it returns | Gallery entry |
|---|---|---|
style() |
applies the house style (light grid, no top/right spines, tab10 cycle) | every entry |
save(fig, path, dpi=110) |
saves (tight, white) and closes the figure | every entry |
match_balls(balls, match_id) |
one match, ordered, with balls_done, score, wkts, is_dismissal |
K-01 to K-06 |
over_table(balls) |
one row per (innings, over): runs, wickets, legal balls, cumulative totals | K-01 |
innings_labels(balls) |
{1: "South Africa 169/5 (20 ov)", β¦} for legends |
K-01, K-02 |
manhattan(balls, ax=None, β¦) |
runs-per-over bars, wickets as X | K-01 |
worm(balls, ax=None, β¦) |
cumulative runs ball by ball | K-02 |
run_rate_chart(balls, innings=2, β¦) |
current v required run rate, with runs per over | K-03 |
partnership_table(balls, innings) |
one row per stand | K-04 |
partnership_bars(balls, innings, β¦) |
stacked stand bars | K-04 |
match_title(matches, match_id) |
"Team1 v Team2, venue, date β result" | K-05 |
match_dashboard(balls, match_id, matches) |
2 Γ 2 figure | K-05 |
interactive_worm(balls, title) |
plotly figure with hover text | K-06 |
outcome_class(balls) |
"dot" / "runs" / "boundary" / "wicket" (bowler's view) | K-08, K-09 |
wagon_wheel(tracked, ax=None, hand="R", β¦) |
π§ͺ wagon wheel | K-07 |
pitch_map(tracked, ax=None, bowler_type=β¦) |
π§ͺ pitch map | K-08 |
beehive(tracked, ax=None, β¦) |
π§ͺ beehive | K-09 |
heatmap(table, ax=None, center=None, β¦) |
annotated heat map, sequential or diverging | K-10, K-11 |
percentile_frame(df, cols, invert=()) |
0β100 percentile ranks | K-12 |
radar(pct, ax=None, β¦) |
spider chart, at most four players | K-12 |
xmr_limits(values, baseline=None) |
centre and natural process limits | K-13 |
control_chart(values, ax=None, baseline=None, β¦) |
individuals (XmR) chart | K-13 |
small_multiples(n, ncols=3, β¦) |
(fig, axes) grid with shared scales |
K-14 |
Constants: PALETTE (tab10), COMPARE, COMPARE_STYLES, COMPARE_MARKERS, TEAM_COLOURS, OUTCOME_COLOURS, OUTCOME_MARKERS, SIM_CAPTION, INK, MUTED, GRID. Every drawing function takes an optional matplotlib ax and returns it, so any chart drops into a dashboard or a small-multiples grid.
Part A β Match charts (real ball-by-ball data)
K-01 Manhattan
The question: which overs went for runs, which were tight, and when did the wickets fall?
Code: charts.manhattan (with charts.over_table underneath).
fig, ax = plt.subplots(figsize=(10, 4.6))
charts.manhattan(m, ax=ax, annotate={(2, 16): ("Tahir: 2 runs,\n2 wickets", -1.6, 17)},
title="Manhattan β Newlands T20I, 25 Jan 2017")
charts.save(fig, "k-01-manhattan.png")

π Figure (described): Twenty pairs of bars, South Africa's in blue and Sri Lanka's in orange, with a red X above an over for each wicket. Sri Lanka's over 16 is a two-run bar with two X's above it, labelled "Tahir: 2 runs, 2 wickets", followed by 19 runs in over 17 and 15 in over 19. The chart shows at a glance that the chase was lost and won in the last five overs.
The over table behind it (Sri Lanka, overs 15β20):
bowler runs wickets cum_runs cum_wkts
over
15 AL Phehlukwayo 2 0 116 2
16 Imran Tahir 2 2 118 4
17 WD Parnell 19 0 137 4
18 D Paterson 7 1 144 5
19 AL Phehlukwayo 15 0 159 5
20 D Paterson 11 0 170 5
Design notes. Bars include all runs (extras too) because the question is what the over cost. Wickets exclude retired hurt and retired not out. Each wicket gets its own X, stacked, so a two-wicket over shows two marks. Headroom above the tallest bar keeps the legend off the data. For a 50-over innings the function thins the x-ticks to every fifth over; for a Test innings, don't use a Manhattan at all β 130 bars say nothing (Chapter 7, Β§7.2).
Where it appears: Chapter 2 (IPL 2026 final), Chapter 3 (IPL 2025 final; 2025 Women's World Cup final), Chapter 7, Chapter 14 (South Africa's chase in the 2024 T20 World Cup final).
K-02 Worm
The question: at any moment, which side was ahead β and how did the two innings compare at the same point?
Code: charts.worm.
fig, ax = plt.subplots(figsize=(10, 4.6))
charts.worm(m, ax=ax, annotate=[(2, 15.0, "116/2 after 15")])
charts.save(fig, "k-02-worm.png")

π Figure (described): Two cumulative-runs lines climb almost on top of each other for 20 overs β blue for South Africa (169/5), orange for Sri Lanka (170/5 in 19.5 overs) β with a dot at each wicket and a dashed target line at 170. Sri Lanka's line is annotated at 116/2 after 15 overs, close to South Africa's score at the same point. The worm shows how even the match was; the Manhattan (K-01) shows where the evenness came from.
Design notes. The x-axis is legal balls Γ· 6, so every delivery is plotted and the line steps at the real pace of the innings. The target line appears only for the second innings. For Tests, pass all four innings and use the lead instead of a target (see the Headingley 2019 case study in Chapter 7, and the four-innings worm in Chapter 2).
Where it appears: Chapter 1, Chapter 2 (Mirpur Test, all four innings), Chapter 3, Chapter 7 (including small multiples of the 2026 knockouts), Chapter 9 (Anchor A annotated), Chapter 10 (India's fourth innings at Brisbane).
K-03 Run-rate chart (the chase chart)
The question: what does the chasing side need from here, and is it keeping up?
Code: charts.run_rate_chart.
fig, ax = plt.subplots(figsize=(10, 4.6))
charts.run_rate_chart(m, innings=2, ax=ax)
charts.save(fig, "k-03-run-rate-chart.png")

π Figure (described): Pale orange bars show Sri Lanka's runs in each over; a solid orange line tracks the current run rate (about 7.7 an over through the middle overs) and a dashed black line the required rate, which starts at 8.5 and jumps to 13.00 after Tahir's 16th over before the 19-run 17th over brings it back. The gap between the two lines is the pressure on the batting side, over by over.
Design notes. Everything is in runs per over on one axis β the bars, the current rate and the required rate β rather than putting the bars on a second scale. The required-rate line stops once the target is reached. The target and total balls come from Cricsheet's target_runs and target_overs, so DLS-revised chases plot correctly.
Where it appears: Chapter 1 (case study: a Chepauk chase), Chapter 3 (case study: the 2024 T20 World Cup final), Chapter 7.
K-04 Partnership bars
The question: who built the innings, and with whom?
Code: charts.partnership_table and charts.partnership_bars.
print(charts.partnership_table(m, 2))
ax = charts.partnership_bars(m, 2)
charts.save(ax.figure, "k-04-partnership-bars.png")
wicket batter_a batter_b runs balls runs_a runs_b extras ended_by
1 N Dickwella WU Tharanga 36 25 13 20 3 WU Tharanga
2 LD Chandimal N Dickwella 9 6 5 4 0 LD Chandimal
3 DM de Silva N Dickwella 71 61 18 51 2 N Dickwella
4 DM de Silva S Prasanna 2 3 1 1 0 DM de Silva
5 BKG Mendis S Prasanna 24 10 2 21 1 BKG Mendis
6 DAS Gunaratne S Prasanna 28 14 11 15 2 unbroken

π Figure (described): Six horizontal bars, opening stand at the top, each split into the first-named batter's runs (blue), the second-named batter's (orange) and extras (grey), labelled with runs and legal balls. The third-wicket stand between de Silva and Dickwella (71 from 61 balls, Dickwella 51 of them) dominates; the last two stands added 52 from 24 balls. The chart makes the shape of the chase obvious: one slow rebuild, then a sprint.
Design notes. A partnership runs until the next wicket of any kind, including retirements. Batter colours here mean "first-named" and "second-named", not teams β the legend says so. Bars are sorted by wicket number, not size, because the order tells the story. For the network view of partnerships across a career, see K-28.
Where it appears: Chapter 7, Chapter 12 (Newlands partnerships for both sides; Laura Wolvaardt's ODI partners).
K-05 Match dashboard
The question: what happened in this match β in one picture?
Code: charts.match_dashboard (Manhattan, worm, run-rate chart and the chasing side's partnerships in a 2 Γ 2 grid, titled with charts.match_title).
fig = charts.match_dashboard(t20i, "936157", games)
charts.save(fig, "k-05-match-dashboard.png")

π Figure (described): The four charts K-01 to K-04 on one page under the match title "South Africa v Sri Lanka, Newlands, Cape Town, 2017-01-25 β Sri Lanka won by 5 wickets". Read clockwise from the top left it answers: which overs mattered, who was ahead, what was needed, and who built the chase.
Design notes. The dashboard is the place for consistency to pay off: blue and orange mean the same teams in three of the four panels, and the fourth (partnerships) labels its colours explicitly. If the match has no second innings (a washout after one innings), the run-rate panel is left blank and the first innings' partnerships are drawn.
Where it appears: Chapter 7 (the 2026 Women's T20 World Cup final; the IPL 2026 final as the Project Checkpoint). It is the core of the match page in the Crease dashboard (Chapter 39).
K-06 Interactive worm
The question: the worm, but with every ball inspectable β over, score, batter, bowler and event on hover.
Code: charts.interactive_worm (plotly).
fig = charts.interactive_worm(m, title="Newlands T20I, 25 Jan 2017 β hover for each ball")
fig.write_html("k-06-interactive-worm.html", include_plotlyjs="cdn")
The rendered file is images/k-06-interactive-worm.html β open it in a browser. (It loads the plotly library from a CDN, so it needs an internet connection the first time.)
π Figure (described): The same two lines as K-02, drawn in plotly. Hovering on any point shows a three-line label β for the second ball of the 16th over of the chase, "15.2 β 116/3", "N Dickwella v Imran Tahir", "WICKET: N Dickwella". Wickets are marked as dots. It is the chart you would embed in a web match report.
Design notes. The hover label uses cricket notation β 15.2 is the second ball of the 16th over β while the axis uses overs elapsed. Keep the same colours as the static worm; an interactive chart is not an excuse for a new palette. Static PNGs remain the book's default because they print and they survive without JavaScript.
Where it appears: Chapter 7, Β§7.3.
Part B β Tracking charts (π§ͺ simulated locations, real outcomes)
π§ͺ Simulated data: ball-tracking (where the ball pitched, where it passed the stumps) and shot direction are not in any public data set.
toolkit/tracking_sim.add_tracking()attaches simulatedsim_*columns to real deliveries: every run, boundary and wicket is real; the locations are drawn from distributions conditioned on the real outcome, format, phase and bowler type, plus a stable per-player "signature" derived from a hash of the name β not the player's real signature. These charts teach how to read and build the views; nothing in them is a fact about where a real player hits or bowls. A franchise with a Hawk-Eye or broadcast tracking feed would plug its real coordinates into the same functions.
The house rule for reproducibility: call add_tracking on a whole competition's deliveries, then filter, because the simulated values depend on the exact set of rows passed in. The gallery does exactly that:
from tracking_sim import add_tracking
tracked = add_tracking(t20i) # ALL men's T20Is first ...
nl = tracked[tracked["match_id"] == "936157"] # ... then filter
(Chapter 7's own wagon-wheel figure called add_tracking on the single match, so its simulated directions differ from K-07's. Both are equally "right" β which is the point: they are simulations.)
K-07 Wagon wheel π§ͺ
The question: where does a batter score β which parts of the ground, and with what?
Code: charts.wagon_wheel (needs sim_shot_angle_deg and sim_shot_dist_m).
s = nl[(nl["batter"] == "N Dickwella") & (nl["wides"] == 0)]
ax = charts.wagon_wheel(s, hand="L", title="N Dickwella β 68 off 51 (left-hander)")
charts.save(ax.figure, "wagon-wheel.png")

π Figure (described): Two circular fields seen from above with the batter at the centre and straight down the ground up the page; each scoring shot is a line β grey for ones to threes, blue for fours, orange for sixes. Dickwella's real innings (68 off 51, ten fours, one six) is drawn with his off side on the left because he bats left-handed; Prasanna's (37 off 16, three fours, three sixes) with the off side on the right. The run totals and boundary counts are real; the directions are simulated.
Design notes. hand="L" mirrors the labels (the simulated angles are already mirrored for left-handers); take the hand from data/reference/player_styles.csv, not from memory. The 30-yard circle is dashed; the rope is drawn at 65 m and sixes are drawn just past it. The legend counts each shot type, so the sample size is always on the chart.
Where it appears: Chapter 7, Chapter 8 (simulated wagon wheels). Chapter 37 builds a broadcast-style wagon wheel with a field overlay in its storytelling module.
K-08 Pitch map π§ͺ
The question: where does a bowler land the ball, and what happens from each length?
Code: charts.pitch_map (needs sim_pitch_m and sim_line_cm).
tahir_id = tracked.loc[tracked["bowler"] == "Imran Tahir", "bowler_id"].value_counts().index[0]
tahir = tracked[(tracked["bowler_id"] == tahir_id) & ~tracked["super_over"]]
ax = charts.pitch_map(tahir, bowler_type="spin", title="Pitch map β Imran Tahir, men's T20Is")
charts.save(ax.figure, "pitch-map.png")

π Figure (described): A vertical strip of pitch with the batter's stumps at the top and shaded spin length bands (yorker, full, good, short, long hop) down the side. Each of Imran Tahir's 821 real legal balls in men's T20Is is a point: grey dots, blue runs, orange squares for boundaries and red X's for his 61 real wickets (economy 6.75). The outcomes are real; where each ball pitched is simulated.
Design notes. The view is from the bowler's end, so a right-hander's off side is on the left of the picture, as on most broadcast pitch maps; the x-axis label says so. Length bands differ for pace and spin (bowler_type="pace" or "spin"), because a "good length" for a leg-spinner is much fuller than for a fast bowler. Pin the bowler by bowler_id, not by name: there are several "Rashid Khan"s, and the same habit protects you everywhere. Above 600 points the markers shrink automatically to limit over-plotting.
Where it appears: Chapter 7 (Bumrah and Rashid Khan in the IPL), Chapter 15 (Malinga and Bravo at the death; Sophie Ecclestone in women's T20Is; line-by-length grids).
K-09 Beehive π§ͺ
The question: where does the ball arrive at the batter β how high, how wide, how straight?
Code: charts.beehive (needs sim_stump_y_cm and sim_stump_z_cm).
rab_id = tracked.loc[tracked["bowler"] == "K Rabada", "bowler_id"].value_counts().index[0]
rab = tracked[(tracked["bowler_id"] == rab_id) & (tracked["phase"] == "death")]
ax = charts.beehive(rab, title="Beehive β Kagiso Rabada, men's T20I death overs")
charts.save(ax.figure, "beehive.png")

π Figure (described): The three stumps drawn to scale (22.86 cm wide, 71.1 cm tall) at the centre of a frame 140 cm wide and 2 m high. Each of Rabada's 427 real legal death-overs balls in men's T20Is is a point at the height and line it passed the stumps β grey dots, blue runs, orange boundary squares and red X's for his 28 real wickets (economy 9.78). Outcomes real, positions simulated.
Design notes. Same viewpoint as the pitch map: from the bowler's end, right-hander's off side on the left. The axes are drawn to equal scale (set_aspect("equal")) so that a ball "a stump's width outside off" looks like it. A beehive is the right picture for an lbw or bowled question (Chapter 15 uses a beehive for its LBW placebo test); a pitch map is the right picture for a length question.
Where it appears: Chapter 7, Chapter 15 (Ecclestone; real Test LBWs on a simulated beehive).
Part C β Comparison charts from crease.charts
K-10 Heat map (sequential)
The question: how does a rate vary across two dimensions at once β here, phase and season?
Code: charts.heatmap (default viridis colour map).
ipl = load_deliveries("ipl")
ipl = ipl[~ipl["super_over"]].assign(year=lambda d: d["start_date"].dt.year)
rr = ipl.groupby(["phase", "year"]).agg(runs=("runs_total", "sum"), legal=("is_legal", "sum"))
rr = (6 * rr["runs"] / rr["legal"]).unstack("year").reindex(["powerplay", "middle", "death"])
ax = charts.heatmap(rr, fmt="{:.1f}", cbar_label="Runs per over",
title="IPL run rate by phase and season, 2008β2026")
charts.save(ax.figure, "heatmap.png")

π Figure (described): Three rows (powerplay, middle overs, death) and nineteen columns (2008β2026), each cell coloured from dark purple (low) to yellow (high) and printed with its run rate. The powerplay row stays between 6.9 and 8.4 runs an over until 2022, then brightens to 8.72 in 2023 and 10.10 in 2026; the death row peaks at 11.21 in 2024. The right-hand edge of the grid is the Impact Player era made visible.
Design notes. Sequential data (magnitudes) gets a sequential, perceptually uniform map (viridis), which also prints legibly in greyscale. Text colour flips between white and near-black by cell luminance so every number is readable. Remember that colour is the least accurate encoding: the printed numbers do the precise work, the colour shows the pattern. The same data as a line chart is K-16 β usually the better choice when one dimension is time and the other has three levels.
Where it appears: Chapter 2 (matches per competition per year), Chapter 3 (phase strike rate for the 2026 leaders; matches by month), Chapter 5 (cross-format correlation matrices), Chapter 7, Chapter 8 (SR+ by phase), Chapter 9 (win-probability tables), Chapter 10 (ranks across nine dimensions), Chapter 15 (π§ͺ length Γ phase; line Γ length), Chapter 18 (strike rate by batting hand and bowling kind).
K-11 Heat map (diverging)
The question: who is above and who is below the league, and in which phase?
Code: charts.heatmap(..., center=0) β passing center switches to the diverging RdBu_r map, symmetric about the centre.
r3 = ipl[ipl["year"] >= 2024]
top10 = batting_summary(r3).head(10).index
ph = batting_summary(r3[r3["batter"].isin(top10)], by=["batter", "phase"])
league = batting_summary(r3.assign(batter="league"), by=["batter", "phase"]).loc["league", "strike_rate"]
diff = ph["strike_rate"].unstack("phase")[["powerplay", "middle", "death"]] - league[["powerplay", "middle", "death"]]
diff = diff.where(ph["balls"].unstack("phase")[["powerplay", "middle", "death"]] >= 60) # suppress thin cells
ax = charts.heatmap(diff.reindex(top10), center=0, fmt="{:+.1f}", cbar_label="SR minus league SR")

π Figure (described): Ten batters (rows) by three phases (columns); each cell shows the batter's strike rate minus the league's in that phase (league 153.12 powerplay, 144.50 middle, 171.61 death, IPL 2024β26). Red cells are above the league, blue below, white at par; cells with fewer than 60 balls are grey "n/a". Abhishek Sharma is +43.6 in the powerplay and +71.8 in the middle overs; Kohli is +27.4 at the death but β7.7 in the middle overs.
Design notes. A diverging map needs a meaningful centre β here zero, "same as the league". The span is symmetric (the deepest blue and deepest red are equally far from par) so the eye does not exaggerate one side. Suppress thin cells rather than colouring them: a 20-ball cell coloured deep red is a lie told in colour. Blueβred, not redβgreen.
Where it appears: Chapter 7 (top 15 IPL run-scorers, 2024β26), Chapter 8 (SR+ heat map), Chapter 9.
K-12 Radar (spider) chart
The question: how does a player profile across several skills, compared with up to three others?
Code: charts.percentile_frame then charts.radar.
pool = batting_summary(r3)
pool = pool[pool["balls"] >= 500]
metrics = ["strike_rate", "average", "boundary_ball_pct", "dot_pct", "boundary_run_pct"]
pct = charts.percentile_frame(pool, metrics, invert=("dot_pct",)) # fewer dots = better
ax = charts.radar(pct.loc[["V Kohli", "SA Yadav", "TM Head", "Abhishek Sharma"]])
strike_rate average boundary_ball_pct dot_pct boundary_run_pct
V Kohli 51.5 100.0 47.0 84.8 30.3
SA Yadav 72.7 63.6 75.8 42.4 72.7
TM Head 93.9 27.3 97.0 15.2 97.0
Abhishek Sharma 100.0 48.5 100.0 36.4 100.0

π Figure (described): Five spokes β strike rate, average, boundary-ball %, dot % (inverted, so fewer dots score higher) and boundary-run % β each running from 0 to 100, the player's percentile among the 33 IPL batters with 500+ balls in 2024β26. Kohli's polygon reaches 100 on average and 85 on dot % but only 30 on boundary-run %; Abhishek Sharma and Head reach the rim on strike rate and boundaries but sit lower on average. The radar shows two different ways to be valuable, not a ranking.
Design notes. Put every spoke on a common 0β100 scale first (percentile_frame), and invert metrics where lower is better. The function refuses more than four players. It uses the OkabeβIto COMPARE colours and a different line style and marker per player. Radars have three real problems β the shape depends on spoke order, area exaggerates differences, and percentiles hide how far apart the raw values are β which is why Chapter 7 follows its radar with strip plots (K-29). Treat the radar as a thumbnail, not evidence.
Where it appears: Chapter 7 (four women's T20I openers).
K-13 Control chart (individuals / XmR)
The question: is this season genuinely different, or within the ordinary season-to-season wobble?
Code: charts.xmr_limits and charts.control_chart.
ipl_games = load_matches("ipl")
ok = ipl_games[(ipl_games["result"] == "win") & ipl_games["method"].isna()] # results, no DLS
first = ipl[(ipl["innings"] == 1) & ipl["match_id"].isin(ok["match_id"])].groupby("match_id")["runs_total"].sum()
year = ipl_games.set_index("match_id")["start_date"].dt.year
avg = first.groupby(first.index.map(year)).mean().round(1)
ax = charts.control_chart(avg, baseline=[y for y in avg.index if y <= 2022],
ylabel="Average first-innings total")
Control chart: baseline 2008-2022 mean 163.1, limits 147.3 to 179.0
Seasons 2023-2026: {2023: 183.0, 2024: 189.6, 2025: 190.9, 2026: 195.7}

π Figure (described): Season averages of IPL first-innings totals as a connected line of points, a solid centre line at 163.1 and dashed natural process limits at 147.3 and 179.0, computed from the shaded 2008β2022 baseline only. Every season from 2023 to 2026 (183.0, 189.6, 190.9, 195.7) sits above the upper limit and is marked as a red square. Fifteen seasons of ordinary variation, then a different system.
Design notes. Limits are centre Β± 2.66 Γ the average moving range (Wheeler's constant for individuals charts), computed from a baseline you choose before looking at the new points. A point outside the limits is a signal worth investigating β here, the Impact Player rule introduced in 2023 is the obvious candidate β not proof of a cause. Points outside are both red and square.
Where it appears: Chapter 7, Β§7.7.
K-14 Small multiples
The question: how do many matches, players or competitions compare β on the same scale?
Code: charts.small_multiples (returns a figure and a list of axes with shared x and y scales).
COMPS = [("ipl", "IPL"), ("bbl", "BBL"), ("psl", "PSL"),
("t20s_male", "Men's T20Is"), ("wpl", "WPL"), ("t20s_female", "Women's T20Is")]
fig, axes = charts.small_multiples(len(COMPS), ncols=3, panel=(3.3, 2.5))
for ax, (code, label) in zip(axes, COMPS):
b = load_deliveries(code)
b = b[~b["super_over"] & (b["innings"] == 1) & (b["start_date"].dt.year >= 2023)]
per = b.groupby(["match_id", "over"])["runs_total"].sum().groupby("over").mean().loc[1:20]
ax.plot(per.index, per.to_numpy(), color=charts.TEAM_COLOURS[1])
ax.set_title(label)

π Figure (described): Six line charts in a 2 Γ 3 grid, all on the same axes, each showing mean first-innings runs in each over from 1 to 20 for matches since 2023, with the powerplay and death overs shaded. The IPL line runs highest β about 10 an over through the powerplay and 12.65 in the 20th over β while women's T20Is run from 4.8 in the first over to 8.03 in the 20th. The shared scale is what lets the eye compare the six shapes and levels directly.
Design notes. Shared axes are the whole point; never let each panel auto-scale. One mark per panel in one colour, with the panel title carrying the identity, avoids a legend with six colours (the house palette never cycles past its ten colours anyway). Put the sample in the title ("IPL (293 matches)"). Men's T20Is here include associate matches, which pulls their curve down.
Where it appears: Chapter 5 (six format-baseline panels), Chapter 7 (worms of the ten knockout matches of 2026), Chapter 18 (pace and spin averages by innings in four conditions; turn direction), Chapter 21 (win percentage against bowling options, one panel per competition).
Part D β General chart types (drawn with plain matplotlib in chapter scripts)
These chart types have no dedicated function in crease.charts; chapters draw them directly with matplotlib, using the module's palette and style. Each entry names a chapter script that draws the book's version.
K-15 Labelled scatter plot
The question: how do two measures relate across many players β and who are the outliers?
Book version: part-01-foundations/chapter-01-cricket-moneyball-moment/code/02_kohli_vs_sky.py; also chapter-04-traditional-statistics-lie/code/02_pace_and_par.py, chapter-08-beyond-batting-average/code/01_metric_table.py.
car = batting_summary(load_deliveries("ipl"))
car = car[car["balls"] >= 1500]
fig, ax = plt.subplots(figsize=(9, 5.4))
ax.scatter(car["strike_rate"], car["average"], s=28, color=charts.PALETTE[0], alpha=0.75)
for name in ["V Kohli", "SA Yadav", "AD Russell", "MS Dhoni"]:
ax.annotate(name, (car.loc[name, "strike_rate"], car.loc[name, "average"]), xytext=(4, 4),
textcoords="offset points", fontsize=8)

π Figure (described): Fifty-eight points, one per IPL batter with at least 1,500 balls (2008β2026), strike rate across and average up, with dotted lines at the two medians and a few famous names labelled. The cloud has almost no slope: the correlation is 0.16. Knowing how often a batter gets out tells you very little about how fast they score β the starting point of Chapter 1 and Chapter 4.
Design notes. Label a handful of points that carry the story, not all of them. Report n and the correlation in the title. Median lines split the plot into four quadrants that readers can name ("fast and reliable"). If one axis is a rate with very different sample sizes behind each point, consider a funnel plot (K-22) instead.
Where it appears: Chapter 1, Chapter 4, Chapter 5 (Test average v T20I strike rate), Chapter 6 (season N v season N+1), Chapter 8, Chapter 9 (runs v WPA), Chapter 10 (average v balls per dismissal), Chapter 12, Chapter 14 (death dot % v boundary %), Chapter 15, Chapter 16 (average v strike rate with iso-curves), Chapter 18 (spinners v right- and left-handers), Chapter 21 (value map), Chapter 22 (venue split-half).
K-16 Line chart over seasons
The question: how has something changed over time, for a few groups at once?
Book version: part-01-foundations/chapter-03-python-for-cricket/code/04_merge_missing_dates.py; also chapter-01-cricket-moneyball-moment/code/01_scoring_revolution.py.
for k, phase in enumerate(["powerplay", "middle", "death"]):
ax.plot(rr.columns, rr.loc[phase], color=charts.COMPARE[k], ls=charts.COMPARE_STYLES[k],
marker=charts.COMPARE_MARKERS[k], label=phase.capitalize())
ax.axvline(2022.5, color=charts.MUTED, ls="--")

π Figure (described): Three lines of runs per over by IPL season β death (dotted, green diamonds), powerplay (solid, blue circles) and middle overs (dashed, orange squares) β with their 2026 values labelled at the right end (10.79, 10.10, 9.31) and a dashed vertical line marking the Impact Player rule from 2023. The powerplay line, flat around 7β8 for fifteen seasons, climbs steeply after 2022 and nearly catches the death overs.
Design notes. Three series β OkabeβIto colours plus three line styles plus three markers: readable in greyscale and under any colour-vision deficiency. Label the lines directly at their ends rather than relying only on a legend. One y-axis. Mark rule changes with a vertical line, but word the label as a date ("from 2023"), not a cause.
Where it appears: Chapter 1, Chapter 2 (extras per match by season), Chapter 3, Chapter 10 (era baselines), Chapter 15 (LBW share by year), Chapter 17 (twos, threes and boundaries by season), Chapter 18 (spin share by phase), Chapter 21, Chapter 22 (choosing to field v chasing win %).
K-17 Sorted dot plot
The question: how do many categories rank on one measure?
Book version: part-01-foundations/chapter-07-visualizing-cricket/code/07_design_principles.py (the "before and after" redesign).
dots = dots.sort_values("run_rate") # one row per competition
y = range(len(dots))
ax.hlines(y, dots["run_rate"].min() - 0.3, dots["run_rate"], color=charts.GRID)
ax.scatter(dots["run_rate"], y, color=charts.COMPARE[0])
ax.set_yticks(y, dots["competition"])
competition women matches run_rate
Women's T20Is True 1420 5.88
Men's T20Is False 2025 7.51
WBBL True 150 7.68
Syed Mushtaq Ali False 47 7.91
BPL False 171 8.01
WPL True 88 8.21
ILT20 False 134 8.22
SA20 False 130 8.31
BBL False 165 8.40
CPL False 136 8.50
LPL False 72 8.72
MLC False 109 8.76
T20 Blast False 505 8.88
PSL False 143 9.05
IPL False 293 9.51

π Figure (described): Fifteen competitions, one per row, sorted from women's T20Is (5.88 runs an over) at the bottom to the IPL (9.51) at the top, each a dot on a faint guide line with its value printed beside it; men's competitions are blue circles, women's orange squares. The ordering does the work a grouped bar chart would make the reader do β and the IPL sits nearly half a run an over clear of the PSL.
Design notes. Sort by the value, not alphabetically. Dots on a common axis beat bars when the axis does not start at zero (bars must start at zero; dots need not). Two groups: colour and marker shape. All matches in the data are included, so the men's T20I figure contains associate cricket β say so whenever you compare across competitions.
Where it appears: Chapter 5 (format fingerprints of twelve batters), Chapter 7 (the redesigned phase chart), Chapter 18 (spin share by host country).
K-18 Stacked horizontal bars (composition)
The question: what share of a whole does each part make up, across a few groups?
Book version: part-01-foundations/chapter-02-cricket-data-sources/code/04_data_quality.py; also chapter-15-pitch-maps-ball-tracking/code/01_real_fingerprints.py, chapter-17-fielding-analytics/code/01_what_the_scorecard_records.py.
left = np.zeros(len(mix))
for kind, col in zip(KINDS, cols):
ax.barh(range(len(mix)), mix[kind], left=left, color=col, label=kind)
left += mix[kind].to_numpy()
wicket_kind caught bowled lbw run out stumped other
Men's Tests 61.4 17.5 16.6 2.6 1.8 0.1
Men's ODIs 60.4 18.8 11.1 7.2 2.4 0.1
Men's T20Is 59.5 21.6 7.8 7.9 3.0 0.2
IPL 66.3 16.7 6.0 8.1 2.6 0.2
Women's ODIs 53.1 20.9 13.0 8.8 4.2 0.1
Women's T20Is 43.4 27.0 10.1 14.2 5.0 0.2

π Figure (described): Six bars that each add to 100% of dismissals (retirements excluded; caught-and-bowled counted as caught), one per format. Caught dominates everywhere β from 66.3% in the IPL down to 43.4% in women's T20Is β while lbw falls from 16.6% in men's Tests to 6.0% in the IPL and run-outs rise to 14.2% in women's T20Is. Composition changes with the format, which is why Chapter 5 treats the formats as different sports.
Design notes. Put the biggest, most stable category first (at the left) so it shares a common baseline and can be compared accurately; later segments float and are harder to compare. Print values inside segments only when the segment is wide enough (here β₯ 6%). No more than six categories β fold the rest into a grey "other".
Where it appears: Chapter 2, Chapter 5, Chapter 15 (by format and phase), Chapter 17 (by competition), Chapter 18 (styles-table coverage), Chapter 21 (bowlers used per innings; an optimal XI's contributions), Chapter 22 (Test results by toss decision).
K-19 Histogram (distribution)
The question: what does the whole spread look like β and has it shifted?
Book version: part-01-foundations/chapter-01-cricket-moneyball-moment/code/03_anchor_previews.py (auction prices); also chapter-10-test-batting/code/04_home_away.py, chapter-06-statistical-thinking/code/06_luck_and_selection.py.
bins = np.arange(60, 300, 10)
ax.hist(old, bins=bins, density=True, color=charts.COMPARE[0], alpha=0.55, label="2008β2022")
ax.hist(new, bins=bins, density=True, histtype="step", lw=2.2, color=charts.COMPARE[1], label="2023β2026")
K-19 IPL first-innings totals (results, no DLS): 2008-22 n=913 mean 163.0 median 164; 2023-26 n=282 mean 189.8 median 192

π Figure (described): Two distributions of IPL first-innings totals on one axis: 913 innings from 2008β2022 as a filled blue histogram (median 164) and 282 innings from 2023β2026 as an orange outline (median 192), with a dotted line at 200. The whole distribution has moved about 28 runs to the right β not just the top tail β which is why the era-specific tables of Chapter 9 are needed.
Design notes. Use density=True when the groups differ in size, so the shapes are comparable. Overlay one filled and one outlined histogram rather than two semi-transparent fills that muddy into a third colour. Choose bin widths in natural units (10 runs). Same bins for both groups.
Where it appears: Chapter 1 (auction prices), Chapter 6 (wins-minus-losses averages; team-season luck v a coin), Chapter 8 (boundary-run %), Chapter 10 (home-minus-away averages), Chapter 14 (death dot %), Chapter 16 (spell lengths). Chapter 2 uses violin plots (a smoothed relative of the histogram) for balls per match by format.
K-20 Interval plot (forest plot)
The question: how uncertain is each estimate β and do the intervals overlap?
Book version: part-01-foundations/chapter-06-statistical-thinking/code/03_bootstrap_ci.py; also chapter-22-toss-venue-conditions/code/01_toss_experiment.py (toss forest plot).
from crease import uncertainty
i26 = ipl[ipl["year"] == 2026]
for name in batting_summary(i26).head(8).index:
sr, lo, hi = uncertainty.strike_rate_ci(i26, name) # innings bootstrap, 95%
batter runs balls sr lo hi
B Sai Sudharsan 722 457 158.0 145.6 168.7
H Klaasen 624 390 160.0 143.3 179.2
Shubman Gill 732 449 163.0 145.6 176.2
V Kohli 675 407 165.8 153.9 176.0
KL Rahul 593 340 174.4 146.7 196.1
Ishan Kishan 602 330 182.4 161.5 203.7
Abhishek Sharma 563 275 204.7 175.5 229.5
V Suryavanshi 776 327 237.3 203.5 268.7

π Figure (described): Eight horizontal intervals, sorted by strike rate, each a dot with a 95% innings-bootstrap interval, labelled with runs and balls, against a dashed line at the IPL 2026 league strike rate of 156.3. Vaibhav Suryavanshi's interval (203.5β268.7) lies entirely to the right of everyone else's except Abhishek Sharma's; the five batters between Sai Sudharsan (158.0) and KL Rahul (174.4) overlap so heavily that a season cannot rank them.
Design notes. The interval is the message; the point is secondary. Resample innings, not balls, because balls within an innings are not independent (Chapter 6). Sort by the estimate. Show the reference line (league, or "no effect" at zero / 50%). With fewer than about ten innings the bootstrap is over-confident β say so, or shrink (K-21).
Where it appears: Chapter 6 (strike rates and averages with intervals), Chapter 11 (de Kock by bowling type, 90% intervals), Chapter 12 (leftβright partner effect), Chapter 21 (win % by bowling options), Chapter 22 (toss winners' and home sides' win % by competition).
K-21 Shrinkage arrows
The question: what is a small sample really telling us β and how far should we pull it back toward the average?
Book version: part-01-foundations/chapter-06-statistical-thinking/code/04_shrinkage.py; also chapter-11-batting-matchups/code/03_shrinkage.py, chapter-22-toss-venue-conditions/code/05_venue_model.py.
s26 = batting_summary(i26)
s26 = s26[s26["balls"] >= 30]
s26["shrunk"] = uncertainty.shrink_normal(s26["strike_rate"], s26["balls"], prior_mean=156.34, k=150)
for b, raw, sh in zip(s26["balls"], s26["strike_rate"], s26["shrunk"]):
ax.annotate("", (b, sh), (b, raw), arrowprops=dict(arrowstyle="->", color=charts.PALETTE[0]))
K-21 shrinkage: 101 IPL 2026 batters with 30+ balls, k = 150 balls toward 156.3
balls strike_rate shrunk
batter
SN Thakur 30 80.0 143.6
M Jansen 45 113.3 146.4
Urvil Patel 64 201.6 169.9

π Figure (described): For each of 101 IPL 2026 batters with 30+ balls, a grey dot (observed strike rate) and an arrow to a blue dot (the estimate shrunk toward the league's 156.3 with a prior worth 150 balls), plotted against balls faced on a log scale. Arrows are long on the left β Shardul Thakur's 80.0 from 30 balls becomes 143.6 β and nearly vanish beyond 300 balls. The picture is the formula: the less evidence, the more the estimate leans on the average.
Design notes. Put sample size on the x-axis (log scale when it spans a wide range) so the funnel shape of shrinkage is visible. Draw arrows from observed to estimate. State k and the prior mean in the legend or caption; the value used here (150 balls) sits inside the 100β190-ball range Chapter 6 estimated for a single IPL season's strike rate. Label only the most-moved points.
Where it appears: Chapter 6, Chapter 10 (Test conversion rates), Chapter 11 (extreme matchups), Chapter 17 (IPL catchers before and after shrinkage), Chapter 22 (venue effects). Chapter 18 and Chapter 22 also draw a cousin of this chart: shrunk bars with the raw value as a tick.
K-22 Funnel plot
The question: which players are genuinely unusual, once we allow for how much luck their sample size permits?
Book version: part-02-batting-analytics/chapter-11-batting-matchups/code/02_head_to_head.py; also part-03-bowling-fielding/chapter-14-bowling-analytics/code/04_expected_wickets.py.
p0 = (f26["fours"].sum() + f26["sixes"].sum()) / f26["balls"].sum() # league rate
n = np.linspace(20, f26["balls"].max(), 300)
for z, ls in [(1.96, "--"), (3.09, ":")]:
se = np.sqrt(p0 * (1 - p0) / n)
ax.plot(n, 100 * (p0 + z * se), ls=ls); ax.plot(n, 100 * (p0 - z * se), ls=ls)
ax.scatter(f26["balls"], f26["boundary_ball_pct"])

π Figure (described): 113 IPL 2026 batters with 20+ balls, boundary-ball % against balls faced, inside dashed (95%) and dotted (99.8%) limits that narrow from left to right around the league rate of 22.7%. Four batters sit above the outer limit and are drawn as orange squares β Vaibhav Suryavanshi, Abhishek Sharma, Finn Allen and Priyansh Arya. Points that look extreme on the left are mostly inside the wide mouth of the funnel: small samples, ordinary luck.
Design notes. The limits come from the binomial distribution around the league rate, so they assume every batter has the league's true rate β points outside are "more extreme than luck alone would usually produce", not "proven better". With 113 batters, expect about five or six outside the 95% band by chance alone; that is why the 99.8% band is drawn. Highlight with shape as well as colour.
Where it appears: Chapter 11 (every head-to-head with 12+ balls), Chapter 14 (wickets above expected).
Part E β Model charts
K-23 Calibration (reliability) diagram
The question: when the model says 30%, does it happen 30% of the time?
Book version: part-02-batting-analytics/chapter-09-batting-impact-context/code/03_calibration.py; also part-03-bowling-fielding/chapter-14-bowling-analytics/code/04_expected_wickets.py. The helpers are crease.impact.calibration_table and crease.impact.brier.
from crease import impact
balls_t20, games_t20 = impact.load_t20(impact.MEN_T20)
s2 = impact.innings_states(balls_t20, games_t20, innings=2)
cut = pd.Timestamp("2023-01-01")
wp = impact.WPTable().fit(s2[s2["start_date"] < cut])
test = s2[s2["start_date"] >= cut]
p = wp.predict(test["runs_needed"], test["balls_left"], test["wkts_in_hand"])
cal = impact.calibration_table(p, test["bat_won"], bins=10)
K-23 calibration: train 5,272 chases, test 3,667 chases; Brier 0.1252
bin predicted observed n
(-0.001, 0.1] 0.031 0.042 98283
(0.1, 0.2] 0.149 0.207 35928
(0.2, 0.3] 0.251 0.309 31496
(0.3, 0.4] 0.350 0.399 25996
(0.4, 0.5] 0.448 0.492 25561
(0.5, 0.6] 0.552 0.592 24475
(0.6, 0.7] 0.652 0.670 25624
(0.7, 0.8] 0.751 0.773 26589
(0.8, 0.9] 0.853 0.865 32073
(0.9, 1.0] 0.965 0.971 75887

π Figure (described): Left: forecast win probability across, observed share of chases won up, with a dashed diagonal for perfect calibration; the ten points for WP v0 (fitted on 5,272 men's T20 chases before 2023, tested on 3,667 since) lie close to but consistently above the diagonal β in the 0.1β0.2 bin the model said 0.149 and chasers won 0.207. Right: bars showing how many pre-ball states fall in each bin, most at the extremes. Chasing became easier after 2022, and an old table underrates chasers.
Design notes. Always show the bin counts next to the curve: a wild point backed by 50 forecasts means nothing. Equal axes, a visible diagonal, and the score (Brier or log-loss) in the text. Test out of time (fit on the past, score the future), never in-sample. The threshold concept here is Chapter 20's.
Where it appears: Chapter 9 (WP v0 out of time), Chapter 14 (expected-wickets model). Chapter 20 calibrates the full win-probability model.
K-24 Win-probability curve
The question: how did each side's chance of winning move, ball by ball?
Book version: part-02-batting-analytics/chapter-09-batting-impact-context/code/04_anchor_a_wp.py.
s1 = impact.innings_states(balls_t20, games_t20, innings=1)
wp = impact.WPTable().fit(s2[s2["match_id"] != "936157"]) # hold the match out
par = impact.ParTable().fit(s1[s1["match_id"] != "936157"])
mw = impact.match_wp(balls_t20, games_t20, "936157", wp, par)
x = np.concatenate([[0], mw["ball_clock"]]) / 6
y = np.concatenate([[1 - mw["wp_bat1"].iloc[0]],
np.where(mw["innings"] == 1, 1 - mw["wp_after"], mw["wp_after"])])
ax.step(x, y, where="post", color=charts.TEAM_COLOURS[2])
K-24 Sri Lanka WP: start of chase 0.431
end of over 15: WP 0.649
end of over 16: WP 0.246
end of over 17: WP 0.565
end of over 18: WP 0.332
end of over 19: WP 0.623

π Figure (described): Sri Lanka's win probability from WP v0 (with this match held out of the fitting) as an orange step line across both innings, shaded orange where Sri Lanka were favourites and blue where South Africa were. It hovers around 0.4β0.5 through South Africa's innings, rises to 0.649 at 116/2 after 15 overs of the chase, falls to 0.246 after Tahir's two-wicket 16th over, swings back and forth through overs 17β19 (0.565, 0.332, 0.623) and finishes at 1. The Manhattan showed where the runs came; this shows what each over was worth.
Design notes. Draw it as steps (where="post"), because probability changes only when a ball is bowled. One team's perspective throughout β label the axis with whose probability it is. Shade above and below 0.5 in the two teams' colours. Hold the match out of the model's training data when you tell its story, otherwise the model has seen the answer. Quote the model's numbers, not round "about 65%" impressions.
Where it appears: Chapter 9 (Anchor A; Mumbai Indians v Delhi Capitals 2023 under two tables; a women's chase under men's and women's tables). Chapter 20 redraws it with the fitted WP v1 model.
K-25 Diverging bars (win probability added)
The question: who moved the needle β for their side and against it?
Book version: part-02-batting-analytics/chapter-09-batting-impact-context/code/04_anchor_a_wp.py (crease.impact.wpa_table).
bat = impact.wpa_table(mw, by="batter")
bat = bat[bat["batter"] != "extras"].sort_values("wpa")
bars = ax.barh(bat["batter"], bat["wpa"],
color=[charts.TEAM_COLOURS[2] if t == "Sri Lanka" else charts.TEAM_COLOURS[1] for t in bat["batting_team"]])
ax.axvline(0, color=charts.INK)
batting_team batter runs balls wpa
Sri Lanka BKG Mendis 2.0 3.0 -0.235
Sri Lanka DM de Silva 19.0 27.0 -0.204
...
Sri Lanka N Dickwella 68.0 51.0 0.157
Sri Lanka DAS Gunaratne 11.0 6.0 0.377
Sri Lanka S Prasanna 37.0 16.0 0.504

π Figure (described): Fourteen batters' win probability added for their own side, as horizontal bars either side of a zero line, Sri Lanka's in solid orange and South Africa's in hatched blue. Prasanna's 37 off 16 is worth +0.504 and Gunaratne's 11 off 6 +0.377 β more than the player of the match, Dickwella (+0.157 for 68 off 51) β while Mendis (β0.235) and de Silva (19 off 27, β0.204) cost Sri Lanka most. Runs and value are not the same thing.
Design notes. Sort by value so the bars form a clean diverging shape. Team identity uses colour and hatching. A single zero line in ink; no gridlines needed on the category axis. Include the runs and balls in the table next to the chart β WPA without the scorecard invites the wrong argument.
Where it appears: Chapter 9 (batting and bowling WPA at Newlands). Chapter 14 draws stacked component bars of Bowling Runs Saved in the same spirit.
Part F β Survival, hazard, network and strip charts
K-26 KaplanβMeier survival curve
The question: how long does a batter's innings last β counting not-outs properly?
Book version: part-02-batting-analytics/chapter-10-test-batting/code/07_survival.py; also part-01-foundations/chapter-05-three-formats/code/03_dismissals_survival.py. Helpers: crease.test_batting.innings_table, survival_frame, km_summary.
from crease import test_batting as tb
from lifelines import KaplanMeierFitter
inns = tb.innings_table(load_deliveries("tests_male"), load_matches("tests_male"))
d = tb.survival_frame(inns[inns["batter"] == "SPD Smith"]) # duration = balls, event = out
kmf = KaplanMeierFitter().fit(d["duration"], event_observed=d["event"])
ax.step(kmf.survival_function_.index, kmf.survival_function_.iloc[:, 0], where="post")
K-26 Kaplan-Meier (men's Tests):
innings dismissals median_balls P(>=50) P(>=100) P(>=200)
batter
V Kohli 210 197 58.0 0.547 0.300 0.121
SPD Smith 227 199 68.0 0.610 0.358 0.168
KS Williamson 195 176 69.0 0.575 0.371 0.165
JE Root 309 283 57.0 0.543 0.336 0.098
M Labuschagne 123 114 56.0 0.559 0.304 0.083

π Figure (described): Four step curves falling from 1 toward 0 as balls faced increase to 300 β Kohli, Smith, Williamson and Root, each in its own colour and line style β plus a grey curve for all batters at positions 1β4. Williamson's and Smith's curves sit highest: 37.1% and 35.8% of their innings last 100 balls or more, against 33.6% for Root and 30.0% for Kohli. Not-out innings are censored, not counted as failures or as completed.
Design notes. Survival curves are steps. Censoring (not-outs) is the reason to use KaplanβMeier rather than "share of innings reaching 100 balls", which miscounts not-outs (Chapter 10 shows the difference). Up to four named curves with COMPARE colours and styles, plus a muted reference curve. State the P(β₯ n) figures in the legend or text; the eye reads vertical gaps between steps poorly.
Where it appears: Chapter 5 (top-order innings survival by format), Chapter 10 (the five batters in the Test debate).
K-27 Hazard curve
The question: is a batter more likely to get out on this ball depending on their score (or balls faced, or the ball's age)?
Book version: part-02-batting-analytics/chapter-10-test-batting/code/02_conversion.py and 06_hazard.py. Helpers: crease.test_batting.hazard_by_score, hazard_by_balls_faced, hazard_by_over.
top = inns.loc[inns["position"] <= 7, ["match_id", "innings", "batter"]]
tests = load_deliveries("tests_male")
hz = tb.hazard_by_score(tests.merge(top, on=["match_id", "innings", "batter"]), tuple(range(0, 155, 5)))
ax.plot([iv.left + 2.5 for iv in hz.index], hz["hazard_pct"], marker="o")
balls outs hazard_pct
bin
[0, 5) 264906 4345 1.640
[5, 10) 162085 2412 1.488
[10, 15) 134368 1981 1.474
[45, 50) 47209 609 1.290
[50, 55) 46794 595 1.272
[80, 85) 19908 275 1.381
[85, 90) 17444 205 1.175
[90, 95) 14930 189 1.266
[95, 100) 12947 138 1.066
[100, 105) 13245 170 1.284

π Figure (described): Dismissals per 100 balls faced, by the batter's score before the ball in five-run bins, for men's Test batters at positions 1β7. Risk is highest on 0β4 (1.64 per 100 balls) and falls to about 1.3 once a batter is set; the shaded nineties are no more dangerous than the eighties (1.27 and 1.07 on 90β94 and 95β99 against 1.38 and 1.18 on 80β84 and 85β89). There is no "nervous nineties" spike in the data.
Design notes. A hazard is a rate per ball at risk, so each point's denominator is the balls faced at that score, which shrinks quickly β print the table, or show the balls, so readers can see where the curve gets noisy. Five-run bins show more texture than Chapter 10's ten-run bins and more noise; the conclusion is the same. Shade the region the claim is about.
Where it appears: Chapter 10 (hazard by score; by balls faced and over of the innings), Chapter 16 (wicket probability by the length of a scoreless streak).
K-28 Network diagram
The question: who bats with whom β and who connects a team's batting?
Book version: part-02-batting-analytics/chapter-12-batting-partnerships/code/04_partnership_network.py. Helpers: crease.partnerships.tag_stands, partnership_table, pair_summary, partnership_network, network_table.
import networkx as nx
from crease.partnerships import tag_stands, partnership_table, pair_summary, partnership_network
pairs = pair_summary(partnership_table(tag_stands(load_deliveries("wpl"))))
G = partnership_network(pairs) # node = batter, edge = pair, attribute runs
core = sorted(G.degree(weight="runs"), key=lambda kv: kv[1], reverse=True)[:20]
H = G.subgraph([n for n, _ in core])
pos = nx.kamada_kawai_layout(H, weight=None)
nx.draw_networkx(H, pos, ax=ax, width=[0.6 + 5 * H[a][b]["runs"] / 1222 for a, b in H.edges])
K-28 WPL partnership network: 125 batters, 452 pairs; drawn core 20 nodes, 23 edges (150+ runs)
Top 5 pairs by runs:
stands runs run_rate teams
pair
MM Lanning & Shafali Verma 27 1222 8.95 Delhi Capitals
H Kaur & NR Sciver-Brunt 24 959 8.45 Mumbai Indians
HK Matthews & NR Sciver-Brunt 22 894 9.14 Mumbai Indians
HK Matthews & YH Bhatia 25 627 6.85 Mumbai Indians
S Mandhana & SFM Devine 14 532 9.04 Royal Challengers Bangalore

π Figure (described): Twenty WPL batters as labelled circles, sized by total partnership runs, joined where a pair has added 150+ runs together, with thicker lines for more runs. The thickest edges are Meg LanningβShafali Verma (1,222 runs in 27 stands) and Nat Sciver-Brunt's stands with Harmanpreet Kaur (959) and Hayley Matthews (894) for Mumbai Indians; Sciver-Brunt sits at the centre of the densest cluster. The network shows teams as webs of pairs, not lists of individuals.
Design notes. Draw only the core (top nodes and heavy edges) β a full network of 125 batters and 452 pairs is a hairball. Encode the most important quantity twice at most (here edge width = pair runs, node size = batter's partnership runs) and keep node colour neutral. Layouts are not data: distance on the page means little, and a different layout seed moves everything. Report the network numbers (degree, betweenness β network_table) in a table alongside. In the gallery a small loop nudges nodes apart so labels do not collide.
Where it appears: Chapter 12 (the IPL network core and the women's T20I network).
K-29 Strip plot (the honest alternative to a radar)
The question: where does a player sit within the whole distribution β not just their percentile?
Book version: part-01-foundations/chapter-07-visualizing-cricket/code/05_radar.py (radar and strips together).
sp = batting_summary(r3, by=["batter", "phase"]).reset_index()
sp = sp[sp["balls"] >= 60]
rng = np.random.default_rng(7)
for i, phase in enumerate(["powerplay", "middle", "death"]):
d = sp[sp["phase"] == phase]
ax.scatter(d["strike_rate"], i + rng.uniform(-0.18, 0.18, len(d)), s=12, color="#b0b0b0")
K-29 powerplay: 66 batters with 60+ balls, median SR 147.4
K-29 middle : 90 batters with 60+ balls, median SR 141.1
K-29 death : 62 batters with 60+ balls, median SR 179.1

π Figure (described): Three horizontal strips β powerplay, middle overs, death β each a cloud of grey jittered points, one per IPL batter with 60+ balls in that phase in 2024β26 (66, 90 and 62 batters; medians 147.4, 141.1 and 179.1). Kohli (blue circles) and Suryakumar Yadav (orange squares) are highlighted in each strip. Unlike a radar, the strip shows the raw values and how crowded the field is around each player.
Design notes. Jitter vertically only, with a fixed seed so the picture reproduces. Grey for the field, COMPARE colours and markers for the highlighted players. Keep the sample threshold in the title. Strips scale to many metrics (one row each) where a radar breaks down after five or six spokes.
Where it appears: Chapter 7 (six metrics for 103 women's T20I batters, four openers highlighted).
Other figures in the book
A few figures are one-offs rather than reusable chart types. They follow the same house style.
| Figure | Where | What it is |
|---|---|---|
| Violin plots of balls per match by format | Chapter 2 | distribution shape per format, log scale |
| Grouped bars of phase strike rate for two batters | Chapter 1, Chapter 6 | the simplest comparison; the Simpson's-paradox panels of Chapter 4 and Chapter 6 |
| Colour-vision simulation of a Manhattan | Chapter 7 | the same chart under normal vision, protanopia and deuteranopia |
| Before-and-after redesign | Chapter 7 | a cluttered grouped bar chart and the sorted dot plot that replaced it (K-17) |
| Pre-match matchup sheets | Chapter 11 | tabular "cards" for the 2026 T20 World Cup semi-finals |
| Scouting cards and case-season panels | Chapter 38 | portfolio-style one-page summaries |
Choosing a chart: question first
| If the question is⦠| Start with |
|---|---|
| Which overs mattered in this match? | Manhattan (K-01) |
| Who was ahead, and when? | Worm (K-02), then win-probability curve (K-24) |
| What does the chasing side need? | Run-rate chart (K-03) |
| Who built the innings? | Partnership bars (K-04); across a career, network (K-28) |
| Where does a batter score / a bowler land it? | π§ͺ Wagon wheel, pitch map, beehive (K-07 to K-09) β labelled as simulated |
| How does a rate vary over two dimensions? | Heat map (K-10, K-11) |
| How do many groups compare on one measure? | Sorted dot plot (K-17); many panels, small multiples (K-14) |
| How have things changed over time? | Line chart (K-16); is the change real? control chart (K-13) |
| How do two measures relate across players? | Labelled scatter (K-15) |
| Is this player genuinely unusual? | Funnel plot (K-22), interval plot (K-20) |
| What is a small sample really saying? | Shrinkage arrows (K-21) |
| What is the whole distribution? | Histogram (K-19), strip plot (K-29) |
| What share is each part? | Stacked bars (K-18) |
| Can I trust these probabilities? | Calibration diagram (K-23) |
| Who added value? | Diverging WPA bars (K-25) |
| How long do innings last? | Survival curve (K-26); risk by score, hazard curve (K-27) |
| How does a player profile across skills? | Strip plot (K-29); radar (K-12) only as a thumbnail |
π Try it β Analyze this match. Pick any T20 match id from
load_matches("ipl")(the IPL 2026 final is a good start) and drawcharts.match_dashboardfor it. Then write two sentences β one from the Manhattan, one from the worm β that a commentator could say on air, and check each against the numbers incharts.over_table.
Answer
python ipl, games = load_deliveries("ipl"), load_matches("ipl") final = games[games["season"] == "2026"].sort_values("start_date").iloc[-1]["match_id"] # "1535465" print(charts.match_title(games, final)) fig = charts.match_dashboard(ipl, final, games) charts.save(fig, "ipl-2026-final.png") print(charts.over_table(charts.match_balls(ipl, final)))Chapter 7's Project Checkpoint draws exactly this figure for the IPL 2026 final (Royal Challengers Bengaluru 161/5 in 18 overs beat Gujarat Titans 155/8). A good on-air sentence names the over and the number, in the form "the nth over went for x and the asking rate fell to y", with n, x and y read offover_tableβ and avoids anything the chart cannot show, such as why a bowler was taken off.β οΈ Common pitfall β a beautiful chart of the wrong comparison. Before styling anything, write down the one comparison the reader must make and check that it sits on a common axis. Most chart failures in cricket media are not ugly; they are charts in which the comparison that matters is encoded as an angle, an area or a colour.
Summary
- Twenty-three functions in
crease.chartsdraw the match, tracking and comparison charts (K-01 to K-14); the rest of the book's charts are plain matplotlib in the same style (K-15 to K-29). - The house rules: colour by job (batting first blue, batting second orange, wickets red X); OkabeβIto plus line style or marker for comparisons; never redβgreen alone; one y-axis; overs 1-based; wagon wheels with a right-hander's off side on the right; pitch maps and beehives from the bowler's end; every simulated-tracking chart labelled.
- Every image here is regenerated on real data by
appendices/code/k_gallery.py; its printed output is the source of every number quoted. - Choose the chart from the question, put the key comparison on a common axis, and show the sample size.