Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gganimate plot not showing and saving bunch of .png's

I am trying to replicate a simple example about gganimate from here. The problem is simple ggplot part works fine but when I add transition_states rstudio starts rendering and then saves bunch of gganim_plotXXXX.png files and doesn't show the expected animation.

First question is obviously: Am I doing something wrong so that animation doesn't work?

Second question is: Is saving bunch of .png files standard for gganimate?

Thanks in advance

library(gganimate)

p <- ggplot(iris, aes(x = Petal.Width, y = Petal.Length)) + 
         geom_point()

anim <- p + 
  transition_states(Species,
                    transition_length = 2,
                    state_length = 1)
anim
like image 716
Onur Guven Avatar asked Jan 09 '20 12:01

Onur Guven


People also ask

What is another way you can save your Gganimate plot other than as a GIF input the file extension?

In order to save the animation to a specific location, you can use the anim_save() function which, like ggplot2::ggsave , defaults to taking the last rendered animation and writes it to a file.

How do I save an animated plot in R?

If you need to save the animation for later use you can use the anim_save() function.


1 Answers

I ran your code and got this error:

Error in l$setup_layer(d, plot) : attempt to apply non-function

And then, I installed the png and gifski packages and restart the R-Studio. It's working. I think, you can try this.

like image 73
E. Zeytinci Avatar answered Oct 22 '22 01:10

E. Zeytinci