Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'The animation object does not specify a save_animation method' #335

Closed
devktpx opened this issue Jul 1, 2019 · 7 comments
Closed

'The animation object does not specify a save_animation method' #335

devktpx opened this issue Jul 1, 2019 · 7 comments

Comments

@devktpx
Copy link

devktpx commented Jul 1, 2019

Hi, I have trouble saving gganimate animations. It would be great if anyone could help.

This is the code I'm trying to compile:

library(gapminder)
library(gganimate)

## standard ggplot2
ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.7, show.legend = FALSE) +
  scale_colour_manual(values = country_colors) +
  scale_size(range = c(2, 12)) +
  scale_x_log10() +
  # Here comes the gganimate specific bits
  labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
  transition_time(year) +
  ease_aes('linear')

anim_save("output.gif")

It runs fine without the last line. However, when I add the last line (anim_save), then I get this error:

Error: The animation object does not specify a save_animation method

Here is my Session Info:

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gganimate_1.0.3 ggplot2_3.1.0   gapminder_0.3.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.19      bindr_0.1.1       magrittr_1.5      hms_0.4.2        
 [5] progress_1.2.0    tidyselect_0.2.5  munsell_0.5.0     colorspace_1.4-1 
 [9] R6_2.3.0          rlang_0.3.0.1     plyr_1.8.4        dplyr_0.7.7      
[13] tools_3.5.1       grid_3.5.1        gtable_0.2.0      withr_2.1.2      
[17] lazyeval_0.2.1    assertthat_0.2.1  tibble_1.4.2      crayon_1.3.4     
[21] bindrcpp_0.2.2    farver_1.0        tweenr_1.0.1      purrr_0.2.5      
[25] glue_1.3.0        stringi_1.2.4     compiler_3.5.1    pillar_1.3.0     
[29] scales_1.0.0      prettyunits_1.0.2 pkgconfig_2.0.2  

Does anyone know, why the error occurs and how I can fix this?

@ismirsehregal
Copy link

Please try the following:

library(gapminder)
library(gganimate)
library(gifski)

## standard ggplot2
myPlot <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.7, show.legend = FALSE) +
  scale_colour_manual(values = country_colors) +
  scale_size(range = c(2, 12)) +
  scale_x_log10() +
  # Here comes the gganimate specific bits
  labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
  transition_time(year) +
  ease_aes('linear')

animate(myPlot, duration = 5, fps = 20, width = 200, height = 200, renderer = gifski_renderer())
anim_save("output.gif")

@justinmeyer
Copy link

ismirsehregal, that worked for me, thanks!

@swinersha
Copy link

Worked for me too. Why has it taken nearly 2 hours to find a solution to this problem? Seems like this is a really cool package but still serious implementation problems.

@BillSeliger
Copy link

This worked perfectly. Thanks!

@estebangatillo
Copy link

I'm really struggling with animate...I copied the plot above exactly (and have attempted multiple other ggplots) and cannot bypass this error:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘animate’ for signature ‘"gganim"’

I'm using the most updated version of gganimate (1.0.5 not 1.0.3).

Here is a simplified example:

[## standard ggplot2
myPlot <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.7, show.legend = FALSE) +
  # Here comes the gganimate specific bits
  transition_time(year) +
  ease_aes('linear')

animate(myPlot, duration = 5, fps = 20)

myPlot works fine - ‘myPlot‘ renders a fine animation. Adding ‘animate‘ leads to the error.

@nick-youngblut
Copy link

The reply to the initial post states to include library(gifski). Such info doesn't appear to be in the gganimate::anim_save() docs nor the Getting started docs. It would be helpful to include such information, given all of the confusion on this topic, which is on display above.

@r-analisededados
Copy link

Hi,
When I save with the anim_save(), the gif does not reproduce, it is static like a common image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants