4

I usually generate a bunch of animations using gganimate and place them inside html to be shown on my reporting server. I would like to join all animations together instead of having a page for each one of them using R.

I follow the answer to this feature request on GitHub that @ThomasP85 (the creator of the gganimate package) wrote regarding this issue:

https://github.com/thomasp85/gganimate/issues/238

Using two examples from gganimate github site:

library(ggplot2)
library(gganimate)

FirstPlot <- 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')

SecondPlot <- ggplot(airq, aes(Day, Temp, group = Month)) + 
  geom_line() + 
  geom_segment(aes(xend = 31, yend = Temp), linetype = 2, colour = 'grey') + 
  geom_point(size = 2) + 
  geom_text(aes(x = 31.1, label = Month), hjust = 0) + 
  transition_reveal(Day) + 
  coord_cartesian(clip = 'off') + 
  labs(title = 'Temperature in New York', y = 'Temperature (°F)') + 
  theme_minimal() + 
  theme(plot.margin = margin(5.5, 40, 5.5, 5.5))

animate(list=(FirstPlot,SecondPlot ), renderer = gifski_renderer(loop = FALSE))

But no success so far.

useRj
  • 1,232
  • 1
  • 9
  • 15

0 Answers0