How to manage parallel processing with animated ggplot2-plot?

前端 未结 2 1588
自闭症患者
自闭症患者 2020-12-21 08:04

I\'m trying to build an animated barplot with ggplot2 and magick that\'s growing on a \"day per day\" base. Unfortunately, I\'ve got tenthousands o

2条回答
  •  旧时难觅i
    2020-12-21 08:29

    I would do

    library(tidyverse)
    library(gganimate)
    x %>% 
      as.tibble() %>% 
      arrange(date) %>%  
      group_by(category) %>% 
      mutate(Sum=cumsum(value)) %>% 
      ggplot(aes(category, Sum, fill = category)) +
      geom_col(position = 'identity') + 
      ggtitle("{frame_time}") +
      transition_time(date) +
      ease_aes('linear') 
    anim_save("GIF.gif")  
    

    If it's to much data I recommend to increase the transition time to months instead of days.

提交回复
热议问题