class: center, middle, inverse, title-slide .title[ #
gganimate - Revealing ] .author[ ###
Son Nguyen
] --- <style> .remark-slide-content { background-color: #FFFFFF; border-top: 80px solid #F9C389; font-size: 17px; font-weight: 300; line-height: 1.5; padding: 1em 2em 1em 2em } .inverse { background-color: #696767; border-top: 80px solid #696767; text-shadow: none; background-image: url(https://github.com/goodekat/presentations/blob/master/2019-isugg-gganimate-spooky/figures/spider.png?raw=true); background-position: 50% 75%; background-size: 150px; } .your-turn{ background-color: #8C7E95; border-top: 80px solid #F9C389; text-shadow: none; background-image: url(https://github.com/goodekat/presentations/blob/master/2019-isugg-gganimate-spooky/figures/spider.png?raw=true); background-position: 95% 90%; background-size: 75px; } .title-slide { background-color: #F9C389; border-top: 80px solid #F9C389; background-image: none; } .title-slide > h1 { color: #111111; font-size: 40px; text-shadow: none; font-weight: 400; text-align: left; margin-left: 15px; padding-top: 80px; } .title-slide > h2 { margin-top: -25px; padding-bottom: -20px; color: #111111; text-shadow: none; font-weight: 300; font-size: 35px; text-align: left; margin-left: 15px; } .title-slide > h3 { color: #111111; text-shadow: none; font-weight: 300; font-size: 25px; text-align: left; margin-left: 15px; margin-bottom: -30px; } </style> <style type="text/css"> .left-code { color: #777; width: 40%; height: 92%; float: left; } .right-plot { width: 59%; float: right; padding-left: 1%; } </style> # Transition: <font color="black"> Reveal </font> `transition_reveal`: Transition between *values* of a variable Principles: - a time variable is mapped on one of the axes - the time variable is also mapped to actual time (our clock) --- # Data ```r library(gganimate) library(ggplot2) library(tidyverse) library(lubridate) df <- read_csv('https://covidtracking.com/data/download/all-states-history.csv') df$month <- month(df$date) ``` --- # Static Plot .left-code[ ```r df %>% filter(state %in% c('NY')) %>% ggplot(aes(y=positive, x=date))+ * geom_line() ``` ] .right-plot[ <img src="9_viz_reveal_files/figure-html/unnamed-chunk-3-1.png" style="display: block; margin: auto;" /> ] --- # Adding transition_reveal .left-code[ ```r df %>% filter(state %in% c('NY')) %>% ggplot(aes(y=positive, x=date))+ geom_line()+ * transition_reveal(date) ``` ] .right-plot[ <img src="9_viz_reveal_files/figure-html/unnamed-chunk-5-1.gif" style="display: block; margin: auto;" /> ] --- # Static Plot .left-code[ ```r df %>% filter(state %in% c('NY','FL')) %>% ggplot(aes(y=positive, x=date, * color=state))+ geom_line() ``` ] .right-plot[ <img src="9_viz_reveal_files/figure-html/unnamed-chunk-7-1.png" style="display: block; margin: auto;" /> ] --- # Adding transition_reveal .left-code[ ```r df %>% filter(state %in% c('NY','FL')) %>% ggplot(aes(y=positive, x=date, color=state))+ geom_line()+ * transition_reveal(date) ``` ] .right-plot[ <img src="9_viz_reveal_files/figure-html/unnamed-chunk-9-1.gif" style="display: block; margin: auto;" /> ] --- # Adding transition_reveal .left-code[ ```r df %>% filter(state %in% c('NY','FL')) %>% ggplot(aes(y=positive, x=date, color=state))+ geom_line()+ * geom_point(size=3)+ transition_reveal(date) ``` ] .right-plot[ <img src="9_viz_reveal_files/figure-html/unnamed-chunk-11-1.gif" style="display: block; margin: auto;" /> ] --- # Adding transition_reveal .left-code[ ```r df %>% filter(state %in% c('NY','FL')) %>% ggplot(aes(y=positive, x=date, color=state))+ geom_line()+ geom_point(size=3)+ geom_text(aes(label = positive), * hjust = -.1, size=5) + transition_reveal(date) ``` ] .right-plot[ <img src="9_viz_reveal_files/figure-html/unnamed-chunk-13-1.gif" style="display: block; margin: auto;" /> ]