Skip to content

Instantly share code, notes, and snippets.

@thomasp85
Created October 11, 2018 19:40
Show Gist options
  • Save thomasp85/14ed997191f7c6d363517a4dd89f090b to your computer and use it in GitHub Desktop.
Save thomasp85/14ed997191f7c6d363517a4dd89f090b to your computer and use it in GitHub Desktop.
An example of embedding a gganimate animation in a pdf
---
title: "PDF Animation Test"
output: pdf_document
header-includes:
- \usepackage{animate}
---
`gganimate` now supports animations inside PDF documents. This feature is only
viewable with Acrobat Reader, however. Remember to include
`\usepackage{animate}` in the preamble and set `fig.show='animate'` in the chunk
options. Further, the framerate is governed by `interval`rather than any
`gganimate` settings:
```{r, fig.show='animate', interval=1/10}
library(gganimate)
ggplot(airquality, aes(Day, Temp, group = Month)) +
geom_line() +
transition_reveal(Month, Day)
```
@MauricioCely
Copy link

Is it possible to get and html_document output with controls? Similar as done in the PDF document.

@manolo20
Copy link

manolo20 commented Jul 22, 2020

You might also want to use transition_reveal(Month) in line 18 instead of transition_revel(Month, Day) as indicated thomasp85/gganimate#270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment