knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

do.call(knitr::read_chunk, list(path = "scripts/tutorial-animations.R"))

Introduction

This tutorial illustrates two different approaches for creating animated plots from temporal analyses. The first is using the base plot tools in R with the gifski package. The second is using gganimate (which uses gifski under the hood). While the gganimate approach might be the more user friendly of the two, it does not appear to have a mechanism available for dynamically adjusting the color scale each frame, so later frames will appear dark as the probability values in the results decrease over time (as seen below). The gifski package simply merges several different plots, so the color scale can be different for each frame. It can also be used with ggplot instead of base plot if users desire the style of ggplot with dynamic color scales.

Setup

<<setup>>

Using gifski

<<gifski>>
knitr::include_graphics("img/gifski.gif")

Using gganimate

<<gganimate>>
knitr::include_graphics("img/gganimate.gif")


andrewmarx/samc documentation built on Nov. 1, 2024, 10:10 p.m.