0

I'm trying to make an animation using the iris dataset and gganimate. This is a sample of my code:

library(gganimate)
library(ggplot2)
library(dplyr)

iris %>%
  ggplot(aes(Sepal.Length, Petal.Length, col = Species)) +
  geom_point() +
  transition_states(Species, transition_length = 2, state_length = 1) +
  ease_aes("cubic-in-out")

Update::

Running the above(04/26/2019) returns:

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

The above error relates to this issue.

Relevant package info:

other attached packages:
[1] dplyr_0.8.0.1   gganimate_1.0.2 ggplot2_3.1.1 

I expected that I would get an animation split along the different Species. However, gganimate seems to only return setosa. I've looked at the documentation that suggests to solve it like:

iris %>%
  ggplot(aes(Sepal.Length, Petal.Length)) + 
  geom_point(aes(colour = Species, group = 1L)) +
  transition_states(Species, transition_length = 2, state_length = 1)+
  ease_aes("cubic-in-out")

This however doesn't seem to make a difference. Perhaps I'm missing something. Your help is greatly appreciated.

EDIT: I have also tried this but it returns nothing:

library(gganimate)
library(magick)
animate(ggplot(mtcars, aes(mpg, disp)) +
          transition_states(gear, transition_length = 2, state_length = 1) +
          enter_fade() +
          exit_fade(), 
        renderer = sprite_renderer())
NelsonGon
  • 13,015
  • 7
  • 27
  • 57
  • 1
    Is this still a problem for you? I just tried the first set of code & everything works fine. If it's some pre-CRAN era issue with the package that can no longer be reproduced in the current package, suggest we close it as such... – Z.Lin Apr 22 '19 at 08:02
  • Thanks. I will try again some time later(not very active) and update on whether to close. – NelsonGon Apr 26 '19 at 03:55
  • @Z.Lin I'm not sure why it doesn't work. I just run it and it gave me an error as updated. – NelsonGon Apr 26 '19 at 08:54
  • 1
    Hmm, I'm still on ggplot2 3.1.0 & gganimate 1.0.1. That seems to be at last part of the reason (according to the GH link you found). – Z.Lin Apr 26 '19 at 09:00

0 Answers0