Vignette

Behind the Viz: Coding the ranked-choice Black Mirror Sankey diagrams

My latest blog post covered using Ranked-Choice voting and reddit user rankings to determine the (second) best Black Mirror Episode. The key visualization was the Sankey diagram, and in this vignette I’ll walk through my R code for how the chart was made. Libraries and Packages library(tidyverse) library(forcats) library(magrittr) library(knitr) library(alluvial) library(ggalluvial) library(extrafont) colortable <- read_csv("c:/Users/blaze/Documents/R_Projects/BlackMirror/color_palette.csv") Lots of packages here: Tidyverse - all encompassing package for data manipulation and visualization forcats - enables better ordering of factor variables (episode names) when plotting magrittr - I did some in-line code, and magritter has some functions like multiply_by() that allow you to perform arithmetic in a %>% pipeline knitr - For kable tables extrafont - Loading of other fonts alluvial - necessary for Sankey plots ggaluvial - enables Sankey plots Also I have my color palette for each episode.