Skip to content

feat: show pitch locations on a strike zone diagram - #75

Open
alex-monroe wants to merge 1 commit into
paaatrick:mainfrom
alex-monroe:strike-zone-display
Open

alex-monroe wants to merge 1 commit into
paaatrick:mainfrom
alex-monroe:strike-zone-display

Conversation

@alex-monroe

Copy link
Copy Markdown

Renders the current at-bat's pitches as numbered, color-coded markers plotted against the per-pitch strike zone bounds from MLB Stats API (pitchData.coordinates.pX/pZ + strikeZoneTop/Bottom). Sits between the matchup and at-bat panes in the live game view.
Screenshot 2026-04-29 at 8 14 25 PM

Renders the current at-bat's pitches as numbered, color-coded markers
plotted against the per-pitch strike zone bounds from MLB Stats API
(pitchData.coordinates.pX/pZ + strikeZoneTop/Bottom). Sits between the
matchup and at-bat panes in the live game view.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@paaatrick

Copy link
Copy Markdown
Owner

Hey thanks for the contribution. I like the compactness of this display a bit better than the previous attempt in the draft #54. A few comments and questions:

  1. It looks like pitches outside of the grid area get clamped to the edges. Is it possible to add an indicator (perhaps with ▲, ▶, etc characters) that the pitch is actually further out than indicated?
  2. Can you add the corresponding pitch numbers (same colors would be nice) to the list of pitches? So for example:
    3 [Foul] ...
    2 [Ball] ...
    1 [Ball] ...
    
  3. There was an issue in Pitch location visualization #54 where the vertical placement of pitches in the text grid didn't seem to track very well with what was shown in the MLB Gameday interface (even when taking the necessary lower "resolution" of the text grid into account). Have you manually verified that the pitch placements in the text grid look reasonable?

tnoff added a commit to tnoff/playball that referenced this pull request Aug 14, 2026
… the pitch list

Answers the review on paaatrick#75.

Pitches further out than the plot goes were being clamped to its edge with
nothing to say so, which is about one pitch in six: over 787 pitches from
three games, 15% land outside. Surround the plot with a one cell ring that
holds an arrow pointing the way the pitch carried on, so the number still
says which pitch it was. Squeezing the ring inside the current footprint
instead would have pushed 28% of pitches out to arrows, and trimming the
plot back to nine rows tall would have doubled the vertical ones, so the
ring is added around the outside and the view grows by two rows.

Mark each pitch in the at-bat list with the same character and colour it
carries in the plot, so the two can be read against each other.

Number pitches by the API's pitchNumber rather than by their position in
the plotted pitches, so that a pitch the API didn't locate doesn't shift
every number after it and leave the list and the plot disagreeing.

The plotting is now in src/strikeZone.js, next to the other game logic,
where the tests can reach it. What went wrong in #54 is that the zone was
drawn on hardcoded rows while pitches were mapped independently, so the
two disagreed about where the edge of the zone was; the test that pins an
edge pitch onto the drawn edge, for several batters' zones, is there to
keep that from coming back.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants