r - 最新的 gganimate:如何在后台有一个固定的情节?
问题描述
在https://github.com/thomasp85提供的最新版本的 gganimate 中,我想选择情节的哪些部分可以在整个动画中保持静态,哪些部分将被动画化。在之前版本的 gganimate 中,您可以在 ggplot 的aes中指定框架。因此,您可以创建一个静态的基本图并在其上绘制动画图。在最新版本中如何实现类似?
解决方案
这已经gganimate
在 GitHub 上的一个问题中得到解决:https ://github.com/thomasp85/gganimate/issues/94
基本上,您可以使用与最初传递给的数据框不同的数据框来指定应为静态的层ggplot
。我提到的 GitHub 票证中的示例是
library(gganimate)
#> Loading required package: ggplot2
ggplot(dat = data.frame(x=1:10,y=1:10), aes(x=x,y=y)) +
geom_point() +
geom_line(data = data.frame(x2 = 1:10, y = 1:10),
aes(x = x2, y = y, group = 1)) +
transition_time(x)
animate(last_plot(), nframes = 50)
在这里,线保持静止,而点在移动。
推荐阅读
- javascript - NativeScript Angular:Android主线程上发生未捕获的异常
- java - JavaFX setText() NullPointerException 即使我设置了控制器和 fxml 标签
- jquery - 所选页码在 JQuery 数据表的服务器端分页中被重置
- tfs-2015 - SSDT - 跟踪 DACPAC 部署中的数据库更改
- javascript - 如何正确缩放图像以适应 maxdim-by-maxdim 正方形区域?
- php - 通过多个数组数据中的数组值返回数组键
- excel - VBA:如何在用户表单列表中均匀地放置项目?
- vbscript - 拆分后vbScript忽略许多空格
- xamarin - Xamarin 存档工具 - 看似正常的错误,但原因不明
- scalatest - println的scalatest Flatespec测试结果