Animation

Welcome to #30DayChartChallenge 2022 day 22

Networks
Published

April 22, 2022

library(tidyverse)
big_dave <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-04-19/big_dave.csv')
times <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-04-19/times.csv')
big_dave%>%glimpse
big_dave%>%arrange(-rowid)%>%head
big_dave1 <- big_dave%>% # DataExplorer::profile_missing()
  select(answer,puzzle_date,puzzle_name) %>%
  filter(!is.na(answer)) %>%
  mutate(puzzle_bigdave=gsub("[[:punct:][:blank:]]\\d*","",puzzle_name))
big_dave1%>%count(answer)
times%>%glimpse
times%>%head
times1 <- times%>%
  select(answer,puzzle_date,puzzle_name) %>% #DataExplorer::profile_missing()
  filter(!is.na(answer))%>%
  mutate(puzzle_times=gsub("[[:punct:][:blank:]]\\d*","",puzzle_name))
times1 %>%count(answer)
df <- big_dave1 %>%
  inner_join(times1,by=c("answer","puzzle_date")) %>%
  arrange(puzzle_date) %>% # 
  mutate(answer=as.factor(answer)) %>% #DataExplorer::profile_missing()
  select(-puzzle_name.x,-puzzle_name.y) %>%
  mutate(year=lubridate::year(puzzle_date),.after=answer,
         year=as.integer(year))
 
df 
df%>%
  ggplot(aes(x=year,y=puzzle_bigdave))+
  geom_col()
library(gganimate)
colors<- colorRampPalette(RColorBrewer::brewer.pal(12, "Paired"))(161)
library(extrafont)
loadfonts()
library(showtext)
# 
font_add_google("Gentium Book Basic","gbb")
font_add_google("Nanum Gothic","ng")
showtext_auto()
p <- df %>%
    pivot_longer(cols=c("puzzle_bigdave","puzzle_times"),
               names_to="names",values_to="values")%>%
  #count(year)
  ggplot(aes(puzzle_date, fct_reorder(values,puzzle_date), color = values)) +
  geom_jitter(show.legend = F,shape=".",color="white")+
  geom_text(aes(label=answer),
            size=9,
            check_overlap = T,family="gbb")+
  scale_color_manual(values=colors)+
  labs(title = "\nSame Answers! Year: {closest_state}\nBigDave & Times puzzles\n",  
       subtitle="\nwords are randomized",
       caption="#30DayChartChallenge 2022 #Day22\n DataSource: #TidyTuesday week16 - Crossword \n DataViz: Federica Gazzelloni\n\n")+
  theme_void() +
  theme(text = element_text(family = "ng", face="bold",color="#F0F8FF"),
        plot.title = element_text(size=28),
        plot.subtitle = element_text(size=18),
        plot.caption = element_text(size=14,vjust=2,hjust=0.5),
        plot.background = element_rect(fill="grey10",color="grey20"),
        panel.background = element_rect(fill="grey10",color="grey20"),
    legend.position = "none")+
   coord_polar(theta = "x") +
  transition_states(year, 
                    transition_length = 2,
                    state_length = 1,
                    wrap = F) +
  shadow_wake(wake_length = 0.5,wrap=F)


anim_save(animate(p,res=100,
                  renderer = gifski_renderer("animation3.gif"),
                  height = 710, width = 610))