Preferred additions to Coffee in the survey of American coffee drinkers
#TidyTuesday
Donut Chart
Author
Aditya Dahiya
Published
May 15, 2024
The Great American Coffee Taste Test
In October 2023, James Hoffmann, along with coffee company Cometeer, conducted the “Great American Coffee Taste Test” via a livestream on YouTube, engaging approximately 4,000 participants across the USA. During the event, participants received four coffee samples from Cometeer without labels, brewing and tasting them while recording their notes and preferences. The survey data from this event was later analyzed by data blogger Robert McKeon Aloe, who delved into the rich demographics and coffee-related questions provided by the participants. However, it’s important to note that this data is voluntary and doesn’t encompass all participants’ responses due to incomplete surveys. Additionally, the dataset represents a sample of James Hoffmann’s fanbase, limiting its generalizability.
How I made this graphic?
Loading required libraries, data import & creating custom functions
Code
# Data Import and Wrangling Toolslibrary(tidyverse) # All things tidy# Final plot toolslibrary(scales) # Nice Scales for ggplot2library(fontawesome) # Icons display in ggplot2library(ggtext) # Markdown text support for ggplot2library(showtext) # Display fonts in ggplot2library(colorspace) # Lighten and Darken colourslibrary(patchwork) # Combining plots# Extras and Annotationslibrary(magick) # Image processinglibrary(ggfittext) # Fitting labels inside bar plots# Load Datacoffee_survey <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2024/2024-05-14/coffee_survey.csv')
# Font for titlesfont_add_google("Niconne",family ="title_font") # Font for the captionfont_add_google("Stint Ultra Condensed",family ="caption_font") # Font for plot textfont_add_google("KoHo",family ="body_font") ts <-80showtext_auto()bg_col <-"#F2EFE9"# Credits for coffeee palettecoffee_pal <-c("#623C2B", "#AF524E", "#736849", "#EBD188")text_col <- coffee_pal[1] |>darken(0.7)text_hil <- coffee_pal[1] |>darken(0.4)# Palettes for inset graphsn2 <-0.1*1:nrow(df2)n2 <- n2 -median(n2)pal2 <-vector()for (i in1:nrow(df2)){ pal2[i] <-darken(coffee_pal[2], n2[i], method ="absolute")}n3 <-0.1*1:nrow(df3)n3 <- n3 -median(n3)pal3 <-vector()for (i in1:nrow(df3)){ pal3[i] <-darken(coffee_pal[3], n3[i], method ="absolute")}# Caption stuff for the plotsysfonts::font_add(family ="Font Awesome 6 Brands",regular = here::here("docs", "Font Awesome 6 Brands-Regular-400.otf"))github <-""github_username <-"aditya-dahiya"xtwitter <-""xtwitter_username <-"@adityadahiyaias"social_caption_1 <- glue::glue("<span style='font-family:\"Font Awesome 6 Brands\";'>{github};</span> <span style='color: {text_hil}'>{github_username} </span>")social_caption_2 <- glue::glue("<span style='font-family:\"Font Awesome 6 Brands\";'>{xtwitter};</span> <span style='color: {text_hil}'>{xtwitter_username}</span>")
Annotation Text for the Plot
Code
plot_title <-"Coffee Habits"plot_caption <-paste0("Data: Great American Coffee Taste Test; Robert McKeon Aloe", " | **Code:** ", social_caption_1, " | **Graphics:** ", social_caption_2 )plot_subtitle <-str_wrap("Insights from the Great American Coffee Taste Test tell is that most Americans add nothing to their coffee – just prefer Black coffee. Apart from them, the common additions to coffee, include milk, dairy, creamers, and sweeteners. The diverse range of sweeteners and dairy products preferred by coffee drinkers across the USA, are also shown below.", 100)# Custom line-breaks (done in MS Word)plot_subtitle <-"Insights from the Great American Coffee Taste Test tell us that most\nAmericans add nothing to their coffee – just prefer Black coffee. Apart\nfrom them, the common additions to coffee, include milk, dairy, creamers,\nand sweeteners. The diverse range of sweeteners\nand dairy products preferred by\ncoffee drinkers across\nthe USA, are also\nshown below."str_view(plot_subtitle)