动画比例参数

问题描述

我正在寻找一种优雅/简洁的方式来在 R 中生成动画,在我的 j 比例变换中移动参数。

假设我有这些数据和图表:

y

根据我想强调全局效果还是局部效果,我可能会选择在 library(tidyverse); library(gganimate); library(scales) my_data <- tibble(time = 1:100,value = (5*sin(time/100))^6 + (1E3*sin(time/5))) scale_plot <- function(sig) { ggplot(my_data,aes(time,value)) + geom_line() + labs(title = paste("sigma =",{{ sig }})) + scale_y_continuous(trans = pseudo_log_trans(sigma = sig)) } 中使用不同的 sigma 参数:

scales::pseudo_lot_trans()

enter image description here

scale_plot(20000) # pretty close to linear

enter image description here

我想要一种优雅/简洁的方式来制作在这些之间切换的动画。我遇到过使用循环生成一系列静态图像,然后使用 scale_plot(200) # toward log gifski 之类的方法将它们编译为 GIF 的方法。 (请参阅 my answer to another question。)理想情况下,我想找到一种使用 animation方法,但到目前为止我只知道如何为数据中的更改或视口中的更改设置动画(例如使用 gganimate),而不是转换的参数。有没有比“手动”构建框架更简洁的方法

解决方法

采用 my answer to another question,这可以通过创建框架然后使用 gganimate::view_manual 包组合它们来实现。使用 animation 是否有更好的方法?

gganimate

enter image description here