Control de velocidad de una gganimation
Quiero reducir la velocidad de transición entre estados cuando usolibrary(gganimate)
.
Aquí hay un mini ejemplo:
# 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)
Mi comportamiento ideal sería mucho más lento (10-100x), por lo que los cambios de color evolucionan gradualmente y nadie tiene una convulsión.
Si trato de usartransition_states()
para obtener más control manual, recibo un gif con cuadros en su mayoría en blanco. He probado varias combinaciones paratransition_legnth=
ystate_length=
sin un efecto notable.
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)