Hi, I am trying to animate a line graph using the animate () feature but I keep getting the error of animation of gg objects not supported. I am able to create an animated line graph using transition_reveal, but the dimensions of the graph come out weird and grainy.
Here is my code:
graph <- ggplot(mydata, aes(x = birds, y = cost)) +
geom_line(color = "green") +
scale_x_reverse (breaks = c(100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0)) +
scale_y_continuous (breaks = c(0.00, 0.50, 1.00, 1.50, 2.00, 2.50, 3.00)) +
labs(x = "Birds)",
y = "Cost",
title = "Cost of birds")
The dataset mydata is an excel file with two columns for the data (the birds is 100-0 in one column and the cost is various values in another column).
I used readxl to connect the excel file to my r studio.
For the transition, I made my static graph and used transition_reveal
graph + transition_reveal(birds, range = c(100,0), keep_last = FALSE) +
anim_save("qfixed", animation = last_animation())
This worked, but I'm unable to change the dimensions and quality of the graph. I also want to stop the graph from animating after it circles once, but am unable to do so.