plot_hexes: Plot Hexagon Shot Chart

Description Usage Arguments Value Examples

View source: R/graphics.R

Description

Plot hexagon shot chart for a player or set of players.

Usage

1
2
plot_hexes(dat, player, ..., variable = "FGP", cellsize = 15,
  scale = TRUE)

Arguments

dat

Data frame object returned from get_shotchart.

player

Player name string or vector of player name strings.

...

Additional arguments to pass to filter.

variable

One of "FGP" or "FGPvLeague" to color code the hexagons according to player field goal percentage or the difference between player field goal percentage and the overall league, respectively.

cellsize

Number of hexagon cells to construct along the x dimension. A larger value results in a finer lattice.

scale

Logical. If set to TRUE then the hexagons are scaled according to shot frequency.

Value

Hexagons overlayed on a plot. Note that you need to run the function draw_halfcourt in order to plot the hexgons on the appropriate court.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# plot shots by LeBron James in 2016-17
draw_halfcourt()
plot_hexes(shots_1617, player = "LeBron James", variable = "FGPvLeague",
           scale = T, cellsize = 15,
           LOC_Y <= 500)

# omit the restricted zone
draw_halfcourt()
plot_hexes(shots_1617, player = "LeBron James", variable = "FGPvLeague",
           LOC_Y <= 500, SHOT_ZONE_BASIC != "Restricted Area")

imadmali/NBAapi documentation built on May 6, 2019, 2:31 p.m.