eip*_*i10 22
gganimate
APIgganimate
已经使用新的API重新设计.现在可以使用下面的代码对框架标题进行动画处理.state_length
并transition_length
设置在给定"状态"(意味着cyl
此处的给定值)和状态之间转换所花费的相对时间量:
p = ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
transition_states(cyl, transition_length=1, state_length=30) +
labs(title = 'Cylinders: {closest_state}')
animate(p, nframes=40)
Run Code Online (Sandbox Code Playgroud)
gganimate
可以github
通过运行 来安装devtools::install_github('thomasp85/gganimate')
帧的子集值将附加到任何预先存在的标题.因此,您可以添加带有说明文字的标题.例如:
library(gganimate)
p = ggplot(mtcars, aes(wt, mpg, frame=cyl)) + geom_point() +
ggtitle("Cylinders: ")
gg_animate(p)
Run Code Online (Sandbox Code Playgroud)
正如您在下面的GIF中所看到的,前缀"Cylinders:"现在被添加到标题之前的值cyl
: