I'd like to use shadow_mark(), but I don't want to see the shadow that gganimate leaves when it's wrapping from the final frame back to the first frame.

I've tried using shadow_mark(wrap = FALSE), but that doesn't seem to do anything.

Here's some test code:


df1 <- data.frame("Time" = c("Summer", "Winter"), 
                  "Blood.Pressure" = c(21,15), 
                  "Name" = c("John","John"))

df1 %>% 
  ggplot(aes(x = Name, y = Blood.Pressure)) + 
  geom_point(size = 5) + 
  coord_flip() + 
  theme(legend.position = 'none') +
    transition_length = 1,
    state_length = 2)  +
  shadow_mark(color = 'black', size = 5, alpha = .25)  +
  labs(title = "John's Blood Pressure In",
       subtitle = "{closest_state}", 
       x = " ", 
       y = "Blood Pressure")

Here's what that plot looks like

I want to keep the shadow that the plot leaves when it's transitioning from Winter to Summer, but I don't want it to create the second shadow--the one that appears when it's transitioning back from Summer to Winter

There's a workaround where I could create a second data frame that uses the Winter Blood Pressure numbers for both states (winter and summer) and plots it on top of existing graph. Feels like there ought to be an easier way though

0 Answers