Skip to contents

Create and return a shot chart for the given shot data, either as an interactive Plotly object or a static ggplot2 plot. Internally calls process_shots() to prepare the data, then overlays the shots on the half‑court background.

Usage

nba_shot_chart(shot_data, interactive = TRUE, title = NULL)

Arguments

shot_data

A data.frame containing at least loc_x, loc_y, and shot_made_flag columns (plus optional shot_distance, shot_value, and game_date for tooltips).

interactive

logical Whether to return an interactive Plotly chart (TRUE) or a static ggplot2 plot (FALSE). Defaults to TRUE.

title

A character string to use as the chart title. Defaults to NULL.

Value

If process_shots() returns a data frame, that data frame is returned. Otherwise, returns a ggplot2 object (when interactive = FALSE) or a Plotly object (when interactive = TRUE).

Examples

if (FALSE) { # \dontrun{
shots_data <- FastBreakR::nba_shots(2025) %>%
  dplyr::filter(player_name == "Stephen Curry")

FastBreakR::nba_shot_chart(
  shot_data = shots_data,
  interactive = FALSE,
  title = "Steph Curry Shot Chart"
)
} # }