grattan_anim_save: Save gganimate animation with Grattan visual styling

Description Usage Arguments Examples

View source: R/grattan_animation.R

Description

'grattan_anim_save()' takes a gganimate animation and formats it in line with the Grattan Institute style guide, in a manner similar to 'grattan_save()' for static plots, then saves the animation to disk.

Usage

1
2
3
4
5
6
7
grattan_anim_save(
  filename,
  animation = gganimate::last_animation(),
  type,
  path = NULL,
  ...
)

Arguments

filename

File to create on disk; required.

animation

The animation objkect to save. Defaults to last rendered animation using 'gganimate::last_animation()'

type

Either "blog" (to save using the Grattan Blog template) or "normal" (to save as a Grattan chart as in a report).

path

Path to save plot to (combined with filename)

...

arguments passed on to animate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library(ggplot2)
library(gganimate)

# First, create a static plot:

static_plot <- ggplot(mtcars, aes(x = wt, y = mpg)) +
 geom_point() +
 labs(title = "Title goes here",
      subtitle = "Subtitle goes here",
      caption = "Notes: some notes. Source: data source") +
 theme_grattan()  +
 theme(axis.title = element_blank())

# Then animate it (this can be in one step with the code above,
# if you'd prefer):

anim_plot <- static_plot +
 transition_states(cyl)

# Then save it. Note that you must specify the chart type. You can optionally
# specify # nframes, fps, and other arguments to gganimate::animate()

## Not run: grattan_anim_save("test.gif", anim_plot, type = "blog",
fps = 5, nframes = 20)
## End(Not run)

MattCowgill/grattantheme documentation built on Jan. 16, 2020, 1:59 a.m.