Мой переход не очень плавный и оставляет тени - PullRequest
0 голосов
/ 15 мая 2019

Я пытаюсь создать GIF-анимацию для моей проблемы с продажами. Однако анимация и переход не являются плавными.

Я пытался работать над темпами перехода, но безуспешно

Выход ниже

gif

gap <- mydata %>%
  group_by(date) %>%
  # The * 1 makes it possible to have non-integer ranks while sliding
  mutate(rank = min_rank(-count) * 1,
         Value_rel = count/count[rank==1],
         Value_lbl = paste0(" ",count)) %>%
  filter(rank <=10) %>%
  ungroup()

p <- ggplot(gap, aes(rank, group = category, 
                     fill = as.factor(category), color = as.factor(category))) +
  geom_tile(aes(y = value/2,
                height = value,
                width = 0.5), alpha = 0.8, color = NA) +
  geom_text(aes(y = 0, label = paste(category, " ")), vjust = 0.2, hjust = 1) +
  geom_text(aes(y=value,label = Value_lbl, hjust=0)) +
  coord_flip(clip = "off", expand = FALSE) +
  scale_y_continuous(labels = scales::comma) +
  scale_x_reverse() +
  guides(color = FALSE, fill = FALSE) +

  labs(title='{closest_state}', x = "", y = "TV Sales",
       caption = "TV Sales Report") +
  theme(plot.title = element_text(hjust = 0, size = 22),
        axis.ticks.y = element_blank(),  # These relate to the axes post-flip
        axis.text.y  = element_blank(),  # These relate to the axes post-flip
        plot.margin = margin(1,1,1,4, "cm")) +

  transition_states(month, transition_length = 2, state_length = 0) +
  ease_aes('cubic-in-out')

animate(p, 200, fps = 10, duration = 40, width = 800, height = 600, renderer = gifski_renderer("gganim.gif"))
...