Grid plot with geom_tile
Let’s show how often teams play against one another.
Code
dg = d %>%
filter(season.type == 'reg') %>%
group_by(home, away) %>%
summarise(games = n())
head(dg)
# A tibble: 6 × 3
# Groups: home [1]
home away games
<chr> <chr> <int>
1 ATL BKN 2
2 ATL BOS 2
3 ATL CHA 2
4 ATL CHI 2
5 ATL CLE 2
6 ATL DAL 1
Code
ggplot(dg, aes(x = home,
y = away,
fill = as.character(games))) +
geom_tile(color = 'black')