I want to slow the transition speed between states when using library(gganimate)
.
Here is a mini example:
# devtools::install_github("thomasp85/gganimate") library(gganimate) # v0.9.9.9999 dat_sim <- function(t_state, d_state) { data.frame( x = runif(1000, 0, 1), y = runif(1000, 0, 1), t_state = t_state*d_state ) } dat <- purrr::map_df(1:100, ~ dat_sim(., 1)) ggplot(dat, aes(x, y)) + geom_hex(bins = 5) + theme_void() + lims(x = c(.3, .7), y = c(.3, .7)) + theme(legend.position = "none") + transition_time(t_state)
My ideal behavior would be much slower (10-100x), so color changes gradually evolve and nobody has a seizure.
If I try to use transition_states()
for more manual control, I get a gif with mostly blank frames. I've tried various combinations for transition_legnth=
and state_length=
without a noticeable effect.
ggplot(dat, aes(x, y)) + geom_hex(bins = 5) + theme_void() + lims(x = c(.3, .7), y = c(.3, .7)) + theme(legend.position = "none") + transition_states(t_state, transition_length = .1, state_length = 2)
To do this, click on the “Timeline” icon in the upper left corner of the Canva editor. This will open up a timeline of all of the different elements on your design. To change the speed of an animation, simply click and drag the element along the timeline. The further you drag it, the faster the animation will play.
I found in docs animate
function which can take fps and detail parameters.
@param fps The frame rate of the animation in frames/sec
@param detail The number of additional frames to calculate, per frame
The result:
p <- ggplot(dat, aes(x, y)) + geom_hex(bins = 5) + theme_void() + lims(x = c(.3, .7), y = c(.3, .7)) + theme(legend.position = "none") + transition_time(t_state) animate(p, fps=1)
Also there you can specify output format such as png, jpeg, svg.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With