This paste brought to you by Pastebin. View Raw

  1. generate_team_chart <- function(team_name) {
  2. plot<- halfP + geom_hex(data = subset(shot_logs, team == team_name),
  3. aes(x =converted_x ,
  4. y =converted_y,
  5. fill = cut(..count.., c(0,1,2, 5, 10, Inf))),
  6. colour = "lightblue",
  7. binwidth = 1,
  8. alpha = 0.75) +
  9. scale_fill_manual(values = c("grey98", "slategray3", "yellow", "red" , "black"),
  10. labels = c("1","2","2-5","5-10","11+"), name = "Count")+
  11. ggtitle(paste(team_name,"Total Shots"))
  12. }