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())