Skip to content

Instantly share code, notes, and snippets.

@pdparker
Created June 21, 2020 02:39
Show Gist options
  • Save pdparker/d7d876836f0cf0c1aee49278db1fc778 to your computer and use it in GitHub Desktop.
Save pdparker/d7d876836f0cf0c1aee49278db1fc778 to your computer and use it in GitHub Desktop.
#devtools::install_github("thebioengineer/tidytuesdayR")
library(tidyverse)
library(ggpomological)
tuesdata <- tidytuesdayR::tt_load(2020, week = 25)
extrafont::ttf_import(paths = "~/Downloads/bayard-desktop")
extrafont::fonts()
#tuesdata$census%>%View
#tuesdata$slave_routes %>% View
#tuesdata$african_names %>% View
#tuesdata$blackpast %>% View
tuesdata$census %>%
filter(region == "USA Total") %>%
mutate(free = black_free/black,
slave = black_slaves/black,
slave_per = paste0(100-ceiling(slave*100),"%"),
adjust = ifelse(slave == 0, .85, slave)) %>%
ggplot(aes(x = year, y = slave))+
geom_area(aes(y = 1), fill = "seagreen") +
geom_area(fill = "gray15") +
theme_pomological(base_family = "BAYARD", 12) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank())+
scale_x_continuous(position = "top",breaks = seq(1790,1870, 10), labels = seq(1790,1870, 10)) +
geom_text(label = "SLAVES\nESCLAVES", y = .50, x = 1830, colour = "white")+
geom_text(label = "FREE - LIBRE", y = .95, x = 1830, colour = "black")+
geom_text(aes(x= year, y = adjust, label = slave_per), nudge_y = .025) +
labs(
title = "PROPORTION OF FREEMEN AND SLAVES AMONG AMERICAN NEGROES.",
subtitle = "PROPORTION DES NÈGRES LIBRES ET DES ESCLAVES EN AMÉRIQUE.",
y = "", x = ""
) +
theme(plot.title = element_text(hjust = 0.5),
plot.subtitle =element_text(hjust = 0.5),
panel.border = element_blank()) +
geom_segment(aes(x = year, xend = year, y = 0, yend = 1),
size = .2, alpha = .2) -> p1
ggsave("~/Downloads/du_bois.pdf", plot = p1,width = 8, height=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment