-
-
Save ryanburge/09414ab3e17264dbbb1777c701146afa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graph <- cces20 %>% | |
mutate(ab = frcode(CC20_332f == 1 ~ "Favor", | |
CC20_332f == 2 ~ "Oppose")) %>% | |
ct(ab, show_na = FALSE, wt = commonweight) | |
graph %>% | |
ggplot(., aes(x = ab, y = pct, fill = ab)) + | |
geom_col(color = "black") + | |
coord_flip() + | |
theme_rb() + | |
scale_y_continuous(labels = percent, limits = c(0, 1)) + | |
lab_bar(top = TRUE, type = pct, pos = .075, sz =6.5) + | |
scale_fill_manual(values = c('#e22f34', "#26b5f8")) + | |
labs(x = "", y = "", title = "Make abortions illegal in all circumstances", caption = "@ryanburge\nData: CES 2020") | |
save("ab_illegal1.png", ht = 2.75, wd = 6) | |
gg <- cces20 %>% | |
filter(CC20_332f == 1) %>% | |
mutate(gender = frcode(gender == 1 ~ "Men", | |
gender == 2 ~ "Women")) %>% | |
ct(gender, show_na = FALSE, wt = commonweight) | |
gg %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(gender))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
# facet_wrap(~ type, ncol =1, strip.position = "left") + | |
scale_fill_manual(values = c("#ffcd00", "#2dc3f2")) + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(legend.text = element_text(size = 24)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "black") + | |
labs(x = "", y = "", title = "Gender Breakdown of Those Opposed to Abortion ", subtitle = "", caption = "@ryanburge\nData: CES 2020") | |
save("ab_ban_gender.png", wd = 9, ht = 3) | |
gg <- cces20 %>% | |
filter(CC20_332f == 1) %>% | |
cces_race(race) %>% | |
ct(race, show_na = FALSE, wt = commonweight) %>% | |
mutate(grp = "Anti-Abortion") | |
gg1 <- cces20 %>% | |
# filter(CC20_332f == 1) %>% | |
cces_race(race) %>% | |
ct(race, show_na = FALSE, wt = commonweight) %>% | |
mutate(grp = "Entire Sample") | |
graph <- bind_rows(gg, gg1) | |
graph %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(race))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ grp, ncol =1, strip.position = "left") + | |
scale_fill_manual(values=met.brewer("Cross", 5)) + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(legend.text = element_text(size = 16)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "black") + | |
geom_text(aes(label = ifelse(race == "White" & pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "white") + | |
labs(x = "", y = "", title = "Racial Breakdown of Those Opposed to Abortion ", subtitle = "", caption = "@ryanburge\nData: CES 2020") | |
save("ab_ban_race.png", wd = 9, ht = 3.5) | |
gg1 <- cces20 %>% | |
filter(CC20_332f == 1) %>% | |
mutate(pid = frcode(CC20_340a == 1 ~ "Very Lib.", | |
CC20_340a == 2 ~ "Lib.", | |
CC20_340a == 3 ~ "Somewhat Lib.", | |
CC20_340a == 4 ~ "Middle of the Road", | |
CC20_340a == 5 ~ "Somewhat Cons.", | |
CC20_340a == 6 ~ "Cons.", | |
CC20_340a == 7 ~ "Very Cons.")) %>% | |
ct(pid, wt = commonweight, show_na = FALSE) %>% | |
mutate(grp = "Anti-Abortion") | |
gg2 <- cces20 %>% | |
# filter(CC20_332f == 1) %>% | |
mutate(pid = frcode(CC20_340a == 1 ~ "Very Lib.", | |
CC20_340a == 2 ~ "Lib.", | |
CC20_340a == 3 ~ "Somewhat Lib.", | |
CC20_340a == 4 ~ "Middle of the Road", | |
CC20_340a == 5 ~ "Somewhat Cons.", | |
CC20_340a == 6 ~ "Cons.", | |
CC20_340a == 7 ~ "Very Cons.")) %>% | |
ct(pid, wt = commonweight, show_na = FALSE) %>% | |
mutate(grp = "Entire Sample") | |
graph <- bind_rows(gg1, gg2) | |
graph %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(pid))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ grp, ncol =1, strip.position = "left") + | |
scale_fill_manual(values = c("#8D021F", "#B2182B","#EF8A62","azure4", "#67A9CF", "#2166AC", "#000080", "darkorchid")) + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(legend.text = element_text(size = 12)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "black") + | |
geom_text(aes(label = ifelse(pid == "Very Lib." & pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "white") + | |
labs(x = "", y = "", title = "Ideological Position of Anti-Abortion Americans", subtitle = "", caption = "@ryanburge\nData: CES 2020") | |
save("ab_ban_id7.png", wd = 9, ht = 3.5) | |
graph1 <- cces20 %>% | |
filter(CC20_332f == 1) %>% | |
mutate(relig = frcode(religpew == 1 ~ "Protestant", | |
religpew == 2 ~ "Catholic", | |
religpew == 3 ~ "Mormon", | |
religpew == 4 ~ "Orthodox", | |
religpew == 5 ~ "Jewish", | |
religpew == 6 ~ "Muslim", | |
religpew == 7 ~ "Buddhist", | |
religpew == 8 ~ "Hindu", | |
religpew == 9 ~ "Atheist", | |
religpew == 10 ~ "Agnostic", | |
religpew == 11 ~ "Nothing in\nParticular", | |
religpew == 12 ~ "Something\nElse")) %>% | |
ct(relig, wt = commonweight, show_na = FALSE) %>% | |
mutate(grp = "Anti-Abortion") | |
graph2 <- cces20 %>% | |
# filter(CC20_332f == 1) %>% | |
mutate(relig = frcode(religpew == 1 ~ "Protestant", | |
religpew == 2 ~ "Catholic", | |
religpew == 3 ~ "Mormon", | |
religpew == 4 ~ "Orthodox", | |
religpew == 5 ~ "Jewish", | |
religpew == 6 ~ "Muslim", | |
religpew == 7 ~ "Buddhist", | |
religpew == 8 ~ "Hindu", | |
religpew == 9 ~ "Atheist", | |
religpew == 10 ~ "Agnostic", | |
religpew == 11 ~ "Nothing in\nParticular", | |
religpew == 12 ~ "Something\nElse")) %>% | |
ct(relig, wt = commonweight, show_na = FALSE) %>% | |
mutate(grp = "Entire Sample") | |
gg <- bind_rows(graph1, graph2) | |
gg %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = relig, y = pct, fill = grp)) + | |
geom_col(color = "black", position = "dodge") + | |
theme_rb(legend = TRUE) + | |
y_pct() + | |
scale_fill_manual(values = c("#dc1c13", "#14133d")) + | |
lab_bar(top = TRUE, type = lab, pos = .015, sz = 4.5) + | |
labs(x = "", y = "", title = "Religious Composition of Anti-Abortion Americans", caption = "@ryanburge\nData: CES 2020") | |
save("anti_ab_religpew.png") | |
graph1 <- cces20 %>% | |
filter(CC20_332f == 1) %>% | |
cces_attend(pew_churatd) %>% | |
ct(att, wt = commonweight, show_na = FALSE) %>% | |
mutate(grp = "Anti-Abortion") | |
graph2 <- cces20 %>% | |
# filter(CC20_332f == 1) %>% | |
cces_attend(pew_churatd) %>% | |
ct(att, wt = commonweight, show_na = FALSE) %>% | |
mutate(grp = "Entire Sample") | |
gg <- bind_rows(graph1, graph2) | |
gg %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(att))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ grp, ncol =1, strip.position = "left") + | |
scale_fill_manual(values=met.brewer("Lakota", 6)) + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(legend.text = element_text(size = 12)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "black") + | |
geom_text(aes(label = ifelse(att == "Never" & pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "white") + | |
labs(x = "", y = "", title = "Religious Service Attendance of Anti-Abortion Americans", subtitle = "", caption = "@ryanburge\nData: CES 2020") | |
save("ab_ban_att.png", wd = 9, ht = 3.25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment