Site icon R-bloggers

Du Bois Visualization Challenge

[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Negro population of Georgia by counties, 1870, 1880 – W.E.B Du Bois

Recreating the the data visualization of W.E.B Du Bois from the 1900 Paris Exposition using modern tools.

https://github.com/ajstarks/dubois-data-portraits/tree/master/challenge/2024

< section id="config" class="level2">

Config

library(tidyverse)
library(sf)
library(janitor)
library(showtext)
library(glue)

_add_google("Play", family = "dubois")
showtext_auto()
< section id="data" class="level2">

Data

Correcting a typo and reprojecting to UTM…

counties <- read_sf("data/DuBoisChallenge - Georgia Counties w 1870 & 1880 data.shp") |> 
  clean_names() |> 
  pivot_longer(starts_with("data"),
               names_to = "year", 
               values_to = "pop", 
               names_pattern = "(\\d{4})") |> 
  mutate(pop = if_else(pop == "> 1000", "< 1000", pop)) |> 
  st_transform("EPSG:32617")
< section id="map" class="level2">

Map

counties |> 
  ggplot() +
  geom_sf(aes(fill = pop), 
          key_glyph = "dotplot",
          color = "#333333") +
  facet_wrap(~ year) +
  scale_fill_manual(
    values = list(
      "< 1000"        = "#516253",
      "1000 - 2500"   = "#E7B14D",
      "2500 - 5000"   = "#E69A96",
      "5000 - 10000"  = "#DE324F",
      "10000 - 15000" = "#CDAA8F",
      "15000 - 20000" = "#744A33",
      "20000 - 30000" = "#32295E"), 
    labels = c(
      "under 1000",       
      "1,000 to 2,500",  
      "2,500 to 5,000",  
      "5,000 to 10,000", 
      "10,000 to 15,000",
      "15,000 to 20,000",
      "20,000 to 30,000"),
    na.value = "#E3CFBC") +
  guides(fill = guide_legend(keywidth = unit(13, units = "mm"),
                             reverse = TRUE)) +
  labs(title = str_to_upper("Negro Population of Georgia by counties"),
       subtitle = "",
       fill = "",
       caption = glue("https://r.iresmi.net/ - {Sys.Date()}
                      inspired by W.E.B Du Bois
                      data: https://github.com/ajstarks/dubois-data-portraits/tree/master/challenge/2024")) +
  theme_void() +
  theme(text = element_text(family = "dubois", size = 20),
        plot.title = element_text(size = 25),
        plot.background = element_rect(fill = "#E6D4C3", color = NA),
        plot.margin = margin(0, .3, 0.1, .3, "cm"),
        plot.caption = element_text(size = 10), 
        plot.caption.position = "plot",
        strip.text = element_text(size = 20, hjust = 0.2))

Figure 1: Recreating negro population of Georgia by counties
< !-- -->
To leave a comment for the author, please follow the link and comment on their blog: r.iresmi.net.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Exit mobile version