thomasp85 / gganimate

A Grammar of Animated Graphics
https://gganimate.com
Other
1.94k stars 308 forks source link

end_pause not working properly #472

Open NathanHeath27 opened 1 year ago

NathanHeath27 commented 1 year ago

Hey,

I'm having an issue where my end_pause is not working properly at all, it skips back to somewhere in the middle of the animation and freezes on that frame instead of the end frame, as well as clipping off all but 1 labels and the end of the lines.

I am using transition_reveal() on a line chart in ggplot2 / gganimate, my code is as follows...

 data

 graph <- ggplot(data = data) +
   geom_line(aes(x = Year , y = Market, color = REGION), linetype = 1,
             size = 1, alpha = 0.75, show.legend = FALSE) +
   geom_text(aes(x = Year , y = Market,
                 label=factor(REGION), group=factor(REGION)),
             hjust = "inward") +
   labs(title = "Market Size by Region",
        y = "Market Size", 
        legend = FALSE) +
   theme_minimal() + 
   ease_aes('linear') +
   theme(plot.margin = unit(c(5,5,5,5), units = "pt")) +
   transition_reveal(Year) +
   enter_grow() +  
   ease_aes('linear') +
   exit_shrink() +
   view_follow(aspect_ratio = 1)

 plot(graph)

 animate(graph, renderer = gifski_renderer(),
         height = 650, width = 850,
         fps = 10, duration = 25,
         end_pause = 25)

it may be worth noting it also throws up this error... "geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?" however this has been present before but not impacted the animation

thomasp85 commented 1 year ago

I am not able to replicate this in general and your code is not reproducible since data is not available to me. Can you please provide a reprex assuming the issue remains

DOH-PXC5303 commented 8 months ago

Hi @thomasp85, I ran into a similar issue. Example below. I'm running ggplot2 v3.4.4 and gganimate v1.0.8. Ran into a S.O. thread that suggested 1.0.7 may not have the same issue but I have not tested that.

library(ggplot2)
library(gganimate)

df <- structure(
  list(Submitter = c("AAA", "BBB", "CCC", "DDD", "EEE", 
                     "AAA", "BBB", "CCC", "DDD", "EEE", "AAA", "BBB", "CCC", "DDD", 
                     "AAA", "BBB", "CCC", "DDD"), 
       Submission_Date = structure(c(19389, 
                                     19389, 19389, 19389, 19389, 19358, 19358, 19358, 19358, 19358, 
                                     19327, 19327, 19327, 19327, 19297, 19297, 19297, 19297), class = "Date"), 
       Cumulative_Count = c(275, 97, 23559, 3300, 878, 263, 97, 
                            23081, 3271, 0, 236, 97, 22727, 3212, 230, 97, 22288, 3206
       )), 
  row.names = c(NA, -18L), 
  class = c("tbl_df", "tbl", "data.frame"))

anim <- ggplot(df,
               aes(x = Submission_Date, y = Cumulative_Count, color=Submitter)) +
  geom_point() +
  geom_line()+
  transition_reveal(Submission_Date)

animate(anim,
        nframes = 120,
        end_pause = 100)
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?

Edit: Ran using gganimate v1.0.7 and found a slightly altered output with lines and points. Output does not have the disappearing line at end pause issue. example