Skip to content

Instantly share code, notes, and snippets.

@dill
Created January 19, 2023 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dill/28bb04fc35b51326f01b23d078f5021e to your computer and use it in GitHub Desktop.
Save dill/28bb04fc35b51326f01b23d078f5021e to your computer and use it in GitHub Desktop.
πŸ€–πŸ„πŸŽ¨ get eqipped with aes()
library(ggplot2)
library(emoGG)
library(readr)
library(tidyr)
library(dplyr)
# let's visualise the content of season 1 of Bob Ross' The Joy of Painting
dat <- read_csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/bob-ross/elements-by-episode.csv")
# just get what we need and select season 1
dat <- dat %>%
pivot_longer(cols=!c("EPISODE", "TITLE"), names_to="thing",
values_to="present") %>%
filter(present==1 & grepl("S01", EPISODE))
# artisanal emoji mapping
emoj <- read.delim(textConnection(
'thing | emoji
# ------------ | ------
BUSHES | 1f333
DECIDUOUS | 1f342
GRASS | 1f33f
RIVER | 1f3de
TREE | 1f332
TREES | 1f966
CABIN | 1f3e0
CLOUDS | 2601
CONIFER | 1f384
MOUNTAIN | 1f5fb
SNOW | 2744
SNOWY_MOUNTAIN | 1f3d4
WINTER | 1f328
FENCE | 1f93a
MOUNTAINS | 26f0
STRUCTURE | 1f3da
SUN | 2600
LAKE | 1f6b0
ROCKS | 1faa8
MOON | 1f315
NIGHT | 1f303
BEACH | 1f3d6
OCEAN | 1f30a
CIRRUS | 26c5'),
sep='|', comment.char="#", strip.white=TRUE)
# merge that
dat <- merge(dat, emoj)
# make the title's nicer to plot
dat$TITLE <- gsub("\\\"", "", dat$TITLE)
dat$TITLE <- tools::toTitleCase(tolower(dat$TITLE))
# boom!
p <- ggplot(dat) +
geom_emoji(aes(x=thing, y=TITLE, emoji=emoji)) +
theme_minimal() +
labs(y="Episode", x="") +
theme(axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
panel.grid = element_blank())
p
@dill
Copy link
Author

dill commented Jan 20, 2023

Screenshot 2023-01-20 at 00 06 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment