Can I do that? Inspiration from a Pudding data visualization.

Can I do that? Inspiration from a Pudding data visualization.

This is my note for learning Can I do that? Inspiration from a Pudding data visualization.

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
27
28
29
30
31
32
33
34
35
36
37
38
39
library(tidyverse)
library(awtools)

#data from the Pudding repo
titles <- read.csv('https://raw.githubusercontent.com/the-pudding/data/master/titletowns/titles.csv', stringsAsFactors = FALSE)

top.titles <- titles %>%
group_by(winner_metro) %>%
summarise(n = n()) %>%
top_n(., 21) %>%
ungroup()

title_type <- titles %>%
mutate(type = case_when(
level == "college" ~ "NCAA",
T ~ sport
)) %>%
inner_join(top.titles)

title_type %>%
ggplot(aes(reorder(winner_metro, n), 1, color = type)) +
coord_flip() +
geom_bar(stat = "identity",
aes(group = rev(index), fill = type),
width = 0.75, color = "white",
size = 1.25, alpha = 0.85) +
a_primary_fill() +
a_plex_theme(plot_title_size = 27.5,
base_family = enfont,
plot_title_family = enfont) +
geom_label(aes(label = n, y = n + 2), family = 'IBM Plex Sans', color = '#444444', label.size = 0, size=3) +
labs(
title = 'Winningest Metro Areas',
subtitle = 'Count of titles from 1870-2018 by North American metro area.',
x = NULL,
y = NULL,
fill = NULL,
caption = 'Data & Chart Inspiration from The Pudding:\nhttps://pudding.cool/2018/11/titletowns/'
)

Use rounded segment?

R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
library(ggchicklet)
title_type %>%
ggplot(aes(reorder(winner_metro, n), 1, color = type)) +
coord_flip() +
geom_chicklet(aes(group = rev(index), fill = type),
width = 0.75, color = "white",
size = 1.25, alpha = 0.85) +
a_primary_fill() +
geom_label(aes(label = n, y = n + 2), family = 'IBM Plex Sans', color = '#444444', label.size = 0, size=3) +
a_plex_theme(plot_title_size = 27.5) +
labs(
title = 'Winningest Metro Areas',
subtitle = 'Count of titles from 1870-2018 by North American metro area.',
x = NULL,
y = NULL,
fill = NULL,
caption = 'Data & Chart Inspiration from The Pudding:\nhttps://pudding.cool/2018/11/titletowns/'
)

# R

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×