-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy path05_flipping_democratic_seats.Rmd
54 lines (43 loc) · 1.54 KB
/
05_flipping_democratic_seats.Rmd
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: flippingseats
# Flipping seats
```{r, echo = F}
library(tidyverse)
df <- tribble(~year, ~percent, ~category,
2006, 3, "POC",
2006, 13, "Women",
2006, 23, "Under 45",
2006, 83, "White men",
2018, 21, "POC",
2018, 68, "Women",
2018, 53, "Under 45",
2018, 24, "White men")
```
---
```{r flipping_seats, echo = F, eval = F}
ggplot(df) +
aes(x = factor(year), y = percent) +
facet_wrap(~ forcats::fct_inorder(category),
nrow = 1) +
geom_col(aes(y = 100), fill = "white",
width = .6, alpha = .1, col = "grey") +
geom_col(width = .6, alpha = .5) +
aes(fill = category == "White men") +
ylim(c(0,100)) +
theme_bw() +
labs(x = "") +
labs(y = "Demographic's percentage \n of the seat flipping") +
aes(group = category) +
geom_line(col = "grey", lty = "dashed",
mapping = aes(x = c(1.3, 1.3, 1.3, 1.3, 1.7, 1.7, 1.7, 1.7))) +
scale_fill_manual(values = c("blue", "darkgrey"), guide = FALSE) +
labs(title = "Who's the face of the 'Blue Wave'?") +
labs(subtitle = "Data: https://twitter.com/williamjordann/status/1063482594938028032 \n --- seats were flipped to democratic in 2006, and --- seats in 2018") +
labs(caption = "Chart by Gina Reynolds")
```
```{r, echo = F, warning=F, message=F, eval = T, fig.show='hide'}
get_what_save_what <- "flipping_seats"
eval(parse(text = paste(knitr:::knit_code$get(get_what_save_what), collapse = "")))
ggsave(paste0("figures/", get_what_save_what, ".png"), dpi = 300)
```
`r apply_reveal("flipping_seats")`
---