Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Latest commit

 

History

History
95 lines (60 loc) · 2.45 KB

transition_time_vs_transition_reveal.md

File metadata and controls

95 lines (60 loc) · 2.45 KB

Difference between transition_time and transition_reveal

Robbie Bonelli 23/11/2018

Build the plot

p1 <-   ggplot(aes(x = year, 
             y = n,
             group = name),data=dat) +
  geom_label(aes(label = name,fill = name),colour = "white", size =  10) +
  theme_bw() +
  theme(panel.grid = element_blank(),
        legend.position = "none",
        title = element_text(colour = "purple",
                             size = 20,
                             face = "bold")
  ) +
  scale_y_log10(labels = scales::comma)

transition_time() leaves a lot of “dirt” behind

p <- p1+transition_time(time = year)

animate(p,nframes = 50)

This can be solved by increasing the number of frames (possibly that’s why the default is 100 frames)

animate(p,nframes = 100)

tansition_reveal() does not leave anything behind, even with a low number of frames

p <- p1+transition_reveal(id = name, along = year)

animate(p,nframes = 50)

tansition_reveal() can track down the trajctory with a line

In contrast, transition_time() will return oy’s of warning error. It is probably because transition time is meant to show ony one data point per id (??)

p2 <- p1  + geom_line(aes(colour = name),size = 1, linetype = "dotted") 


p <- p2 + transition_reveal(id = name, along = year)


animate(p,nframes = 50)

tansition_reveal() and tansition_time() need a different parameter that needs to be passed for the label of the frame.

frame_along for tansition_reveal() and frame_time for transition_time() and

p2 <- p1  + labs( title = "number of bubs dubbed in {frame_along} ", y = "n babies" ) 


p <- p2 + transition_reveal(id = name, along = year)


animate(p,nframes = 50)

p2 <- p1 +   labs( title = "number of bubs dubbed in {frame_time} ", y = "n babies" ) 


p <- p2 + transition_time(time = year)


animate(p,nframes = 50)