15 tutorials

Baseball

MLB Statcast is the richest free data in sports. Pull it with pybaseball and build leaderboards, heatmaps and more.

Start with the pybaseball first-pull tutorial to get real Statcast data flowing, then the Pythagorean expected-standings tutorial to learn the win-expectation toolkit. From there the exit-velocity leaderboard, pitch-location heatmap and spray-chart builds are independent — pick whichever output you want to own first. If an API ever misbehaves, the bundled sample data keeps every tutorial runnable offline.

Level:
Your first real Statcast pull, cached, with an exit-velocity histogram.
Baseball Beginner

Pull Your First MLB Data with pybaseball

Install pybaseball, turn on caching, and pull a week of real Statcast data — ending with an exit-velocity histogram that proves the data is really there.

~8 min
Wins and losses stacked into a single bar per team to show composition.
Baseball Beginner

Stacked Bar Charts: Win-Loss Composition

Stack wins and losses into one bar per team to show composition — and learn when stacking clarifies a comparison and when it just muddies the picture.

~5 min
A run-differential line shaded green above the league average and red below it.
Baseball Beginner

fill_between: Shade Above and Below a Baseline

fill_between() paints the area between two lines; its where= mask colors above- and below-average regions differently, with interpolate=True closing the wedge.

~5 min
A pitch-location heatmap for one pitcher with the strike zone drawn on top.
Baseball Intermediate

Make a Pitch-Location Heatmap in Python

Use a single pitcher's Statcast data to build a 2-D location heatmap, draw the strike zone from the catcher's view, and read what the hot spots tell you.

~8 min
A hitter's batted balls plotted on a baseball field, by outcome.
Baseball Intermediate

Build a Hitter's Spray Chart

Turn Statcast hit coordinates into a spray chart on a field you draw yourself, colored by outcome, to see whether a hitter pulls or uses the whole field.

~9 min