resize_hexes: Resize Hexagons

Description Usage Examples

View source: R/misc.R

Description

Resize hexagons according to the frequency of shots binned in the hexagon cell.

Usage

1
resize_hexes(hex_grid)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Construct hexagon shot chart (area/color varying)
hex_grid <- half_court_hex(cellsize = 20)
hex_grid <- merge_shot_data(hex_grid, dat_filt, hex = TRUE)
resized_hexes <- resize_hexes(hex_grid)
# Plot hexagon shot chart
breaks <- seq(0, max(hex_grid@data$FGP, na.rm = TRUE), length.out = 10)
plotclr <- c("#236e96", "#15b2d3", "#5abccc", "#ffbe42", "#ff7f00", "#f4543b", "#f4143b")
colcode <- plotclr[findInterval(resized_hexes@data$FGP, breaks)]
draw_halfcourt()
plot(resized_hexes, col = colcode, border = NA, add = TRUE)

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