gganimate:具有不同几何形状和时间点的两层

问题描述

问题类似于this问题,但此处两层使用不同的几何形状geom_tilegeom_point。想法是让图块仅在第2、5、8帧中的不同位置显示,并且该点在每帧中沿对角线移动。

尝试运行以下示例时,出现错误:

错误:时间数据在所有图层中必须是同一类

示例

require(data.table)
require(ggplot2)
require(gganimate)

# 3 tiles along x = 10-y; present at time points 2,5,8
dtP1 = data.table(x = c(1,9),y = c(9,1),t = c(2,8))

# 9 points along x=y; present at every time point
dtP2 = data.table(x = 1:9,y = 1:9,t = 1:9)

p = ggplot() +
    geom_tile(data = dtP1,aes(x = x,y = y),color = "#000000") +
    geom_point(data = dtP2,color = "#FF0000") +
    gganimate::transition_time(t) +
    gganimate::ease_aes('linear')

pAnim = gganimate::animate(p,renderer = av_renderer("~/test.mp4"),fps = 1,nframes = 9,height = 400,width = 400)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)