Created
October 11, 2018 19:40
-
-
Save thomasp85/14ed997191f7c6d363517a4dd89f090b to your computer and use it in GitHub Desktop.
An example of embedding a gganimate animation in a pdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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) | |
``` |
Is there a way to remove the control buttons? R chunk options are fig.show='animate',out.width="60%", interval=1/10,
and the code is
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
# Here comes the gganimate code
transition_states(
gear,
transition_length = 2,
state_length = 1
) +
enter_fade() +
exit_shrink() +
ease_aes('sine-in-out')
Is it possible to get and html_document output with controls? Similar as done in the PDF document.
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
One minor comment: here the knitr should use the development version, else unable to work, at least to me already.
Source: https://stackoverflow.com/questions/52884403/issue-knitting-to-a-pdf-document-using-gganimate-animation-not-included