Skip to main content

shotCells

import * as Plot from "@observablehq/plot";
import { shotCells, surface } from "@sportsdataverse/sdvplot/plot";
import { cellsVsLeague, leagueIndex } from "@sportsdataverse/sdvplot/shots";

const shots = [
{ x_legacy: -1, y_legacy: 7, shot_distance: 1, shot_value: 2, shot_result: "Made" },
{ x_legacy: 0, y_legacy: 0, shot_distance: 0, shot_value: 2, shot_result: "Missed" },
{ x_legacy: -44, y_legacy: 252, shot_distance: 26, shot_value: 3, shot_result: "Made" },
];
// the three shots stand in for the league; the gallery's hex chart uses the 2025-26 league's index
const cells = cellsVsLeague(shots, leagueIndex(shots, 15));
const court = surface("nba", { displayRange: "defense" });
Plot.plot({ ...court.scales, marks: [...court.marks, shotCells(cells, { r: 15 })] });

Tags: docstring · shotCells. All sdvplot examples.