class: center, middle, inverse, title-slide # gganimate ## a ‘flipbookr’ tutorial ### Gina Reynolds --- - transition - change the data - viewpoint - changing field of view - shadows - memory --- class: split-40 count: false .left-panel-transitions-rotate[ ```r options(gganimate.nframes = 50) library(tidyverse) library(gapminder) ggplot(data = gapminder) + aes(x = gdpPercap) + aes(y = lifeExp) + aes(group = country) + geom_point() + aes(color = continent) + aes(size = pop) + scale_x_log10() + gganimate::transition_time(time = year) + NULL -> g animate(plot = g) ``` ] .right-panel-transitions-rotate[ ![](gganimate_files/figure-html/transitions_rotate_1_output-1.gif)<!-- --> ] --- class: split-40 count: false .left-panel-transitions-rotate[ ```r options(gganimate.nframes = 50) library(tidyverse) library(gapminder) ggplot(data = gapminder) + aes(x = gdpPercap) + aes(y = lifeExp) + aes(group = country) + geom_point() + aes(color = continent) + aes(size = pop) + scale_x_log10() + * gganimate::transition_reveal(along = year) + NULL -> g animate(plot = g) ``` ] .right-panel-transitions-rotate[ ![](gganimate_files/figure-html/transitions_rotate_2_output-1.gif)<!-- --> ] --- class: split-40 count: false .left-panel-transitions-rotate[ ```r options(gganimate.nframes = 50) library(tidyverse) library(gapminder) ggplot(data = gapminder) + aes(x = gdpPercap) + aes(y = lifeExp) + aes(group = country) + geom_point() + aes(color = continent) + aes(size = pop) + scale_x_log10() + * gganimate::transition_manual(frames = continent) + NULL -> g animate(plot = g) ``` ] .right-panel-transitions-rotate[ ![](gganimate_files/figure-html/transitions_rotate_3_output-1.gif)<!-- --> ] <style> .left-panel-transitions-rotate { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-transitions-rotate { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-transitions-rotate { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Graphing as time series --- class: split-40 count: false .left-panel-time_series_point-rotate[ ```r options(gganimate.nframes = 10) library(gapminder) ggplot(data = gapminder) + aes(x = year) + aes(y = lifeExp) + aes(group = country) + geom_point(size = 8) + aes(color = continent) + aes(size = pop) + facet_wrap(~ continent) + gganimate::transition_time(time = year) + NULL -> g animate(plot = g) ``` ] .right-panel-time_series_point-rotate[ ![](gganimate_files/figure-html/time_series_point_rotate_1_output-1.gif)<!-- --> ] --- class: split-40 count: false .left-panel-time_series_point-rotate[ ```r options(gganimate.nframes = 10) library(gapminder) ggplot(data = gapminder) + aes(x = year) + aes(y = lifeExp) + aes(group = country) + geom_point(size = 8) + aes(color = continent) + aes(size = pop) + facet_wrap(~ continent) + * gganimate::transition_reveal(along = year) + NULL -> g animate(plot = g) ``` ] .right-panel-time_series_point-rotate[ ![](gganimate_files/figure-html/time_series_point_rotate_2_output-1.gif)<!-- --> ] --- class: split-40 count: false .left-panel-time_series_point-rotate[ ```r options(gganimate.nframes = 10) library(gapminder) ggplot(data = gapminder) + aes(x = year) + aes(y = lifeExp) + aes(group = country) + geom_point(size = 8) + aes(color = continent) + aes(size = pop) + facet_wrap(~ continent) + * gganimate::transition_manual(frames = continent) + NULL -> g animate(plot = g) ``` ] .right-panel-time_series_point-rotate[ ![](gganimate_files/figure-html/time_series_point_rotate_3_output-1.gif)<!-- --> ] <style> .left-panel-time_series_point-rotate { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-time_series_point-rotate { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-time_series_point-rotate { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- # geom_line(), geom_path --- class: split-40 count: false .left-panel-time_series-1[ ```r options(gganimate.nframes = 25) library(gapminder) ggplot(data = gapminder) + aes(x = year) + aes(y = lifeExp) + aes(group = country) + geom_line() + geom_point(size = 8) + aes(color = continent) + aes(size = pop) + facet_wrap(~ continent) + gganimate::transition_reveal(along = year) + NULL -> g animate(plot = g) ``` ] .right-panel-time_series-1[ ![](gganimate_files/figure-html/time_series_1_1_output-1.gif)<!-- --> ] <style> .left-panel-time_series-1 { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-time_series-1 { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-time_series-1 { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- class: split-40 count: false .left-panel-time_series_path-1[ ```r options(gganimate.nframes = 30) library(gapminder) ggplot(data = gapminder) + aes(x = gdpPercap) + aes(y = lifeExp) + aes(group = country) + geom_path() + geom_point(size = 5) + aes(color = continent) + scale_x_log10() + facet_wrap(~ continent) + gganimate::transition_reveal(along = year) + NULL -> g animate(plot = g) ``` ] .right-panel-time_series_path-1[ ![](gganimate_files/figure-html/time_series_path_1_1_output-1.gif)<!-- --> ] <style> .left-panel-time_series_path-1 { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-time_series_path-1 { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-time_series_path-1 { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style>