forked from toddwschneider/ballr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheatmap_chart.R
26 lines (25 loc) · 943 Bytes
/
heatmap_chart.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
generate_heatmap_chart = function(shots, use_short_three = FALSE) {
if (use_short_three) {
base_court = short_three_court
} else {
base_court = court
}
base_court +
stat_density_2d(
data = shots,
aes(x = loc_x, y = loc_y,
fill = ..density..),
geom = "raster", contour = FALSE, interpolate = TRUE, n = 200
) +
geom_path(data = court_points,
aes(x = x, y = y, group = desc, linetype = dash),
color = "#999999") +
scale_fill_gradientn(colors = inferno_colors, guide = FALSE ) +
scale_colour_gradientn("Shot frequency ",
limits = c(0, 1),
breaks = c(0, 1),
labels = c("lower", "higher"),
colours = inferno_colors,
guide = guide_colorbar(barwidth = 15)) +
theme(legend.text = element_text(size = rel(0.6)))
}