Open kocabiyik opened 5 years ago
This might be of interest for an example. It animates and sonifies a loess curve for accessibility.
`
library(lattice) library(ggplot2) library(sonify) library(gganimate) library(broom) library(tidyverse) library(av)
l2 <- loess(NOx ~ E, ethanol) fit <- augment(l2) s <- sonify(l2$x, l2$fitted, duration = 4, play = TRUE) writeWave(s, filename = "audio")
df <- tibble(fit$E, fit$NOx) names(df) <- c("x", "y")
p <- fit %>% arrange(.fitted) %>% ggplot(aes(E, NOx)) + geom_line(aes(y = .fitted), color = "red") + transition_reveal(E, keep_last = TRUE) + geom_point(data = df, aes(x, y))
anim_p <- animate(p, renderer = av_renderer(), duration = 10)
anim_save(filename = "annimation.mp4", animation = anim_p)
av::av_encode_video(input = "annimation.mp4", output = "both.mp4", audio = "audio")`
The new demo video: https://www.youtube.com/watch?v=cZAngjZRYpA