gganimate 不会显示移动点的踪迹

gganimate won't show trail to moving points

我正在尝试创建我制作的 ggplot 的动画,但它不会使用 transition_time 创建轨迹,我已经阅读并看到人们使用 transition_reveal 但得到这个错误消息

png::readPNG(frames1, native = TRUE) 错误: 无法打开 /var/folders/_z/y8zrlqwj4fs2wgkxyrztvqhr0000gn/T//Rtmp2zZJvG/1a492ff72039/gganim_plot0001.png 此外:有 50 个或更多警告(使用 warnings() 查看前 50 个)

下面是函数transition_time

的动图

在最后一帧,我试图让它看起来像我在下面制作的原始 ggplot

这是我的一部分数据

library(ggplot2)
library(dplyr)
library(gganimate)

RCT_NIH_mod <- structure(list(Year.Published = c(1993, 1993, 1993, 1993, 1993, 
1993, 1993, 1994, 1994, 1994, 1994, 1994, 1994, 1994, 1995, 1995, 
1995, 1995, 1995, 1995, 1995), group = structure(c(2L, 3L, 4L, 
5L, 6L, 1L, 7L, 2L, 3L, 4L, 5L, 6L, 1L, 7L, 2L, 3L, 4L, 5L, 6L, 
1L, 7L), .Label = c("Mino", "Alaska", "Asia", 
"Lack", "Islander", "Patino", "Native"
), class = "factor"), numPapers = c(791L, 791L, 791L, 791L, 791L, 
791L, 791L, 991L, 991L, 991L, 991L, 991L, 991L, 991L, 1129L, 
1129L, 1129L, 1129L, 1129L, 1129L, 1129L), numMentions = c(0L, 
1L, 17L, 0L, 4L, 22L, 1L, 0L, 4L, 13L, 0L, 8L, 26L, 0L, 0L, 8L, 
31L, 0L, 8L, 54L, 7L), freqMentions = c(0, 0.00126422250316056, 
0.0214917825537295, 0, 0.00505689001264223, 0.0278128950695322, 
0.00126422250316056, 0, 0.00403632694248234, 0.0131180625630676, 
0, 0.00807265388496468, 0.0262361251261352, 0, 0, 0.0070859167404783, 
0.0274579273693534, 0, 0.0070859167404783, 0.0478299379982285, 
0.00620017714791851)), row.names = c(NA, -21L), class = c("tbl_df", 
"tbl", "data.frame"))
Graph_NIH_anim <- RCT_NIH_mod %>%
  ggplot(aes(x = Year.Published, y = freqMentions, group = group)) + 
    geom_line() +
    geom_point(aes(shape = group)) +
    scale_x_continuous(breaks = min(RCT_NIH_mod$Year.Published):max(RCT_NIH_mod$Year.Published)) +
    scale_y_continuous(breaks = seq(0, .1208, .02),
                     labels = scales::percent_format(accuracy = 1), 
                     limits = c(0, .1208)) +
    scale_shape_manual(values = 1:nlevels(RCT_NIH_mod$group), 
                       breaks = c("Mino", "Alaska", "Asia", 
"Lack", "Islander", "Patino", "Native"), 
                       labels = c("1", "2", "3", "4s", "5", "6", "7") ) +
    theme_classic() +
    theme(legend.title = element_blank()) +
                      xlab('!') +
                      ylab('  (%)') +
    theme(axis.text.x=element_text(angle=45,hjust=1)) + 
    theme(panel.border = element_blank(),
          axis.line= element_line(colour="black")) + 
    theme(legend.position = c(.16,.78)) +
    theme(legend.background = element_blank()) + 
    ggtitle("!") +
    transition_reveal(RCT_NIH_mod$Year.Published) +
    labs(title = "Year: {frame_time}") 
Graph_NIH_anim

将最后两行替换为transition_reveal(Year.Published) + labs(title = "Year: {round(frame_along, 0)}"),我得到下面的动画。与 ggplot2 中的 aes() 调用一样,transition_* 项正在查找不带 table 和 $ 的列名,而 transition_reveal 具有与 transition_time.

不同的计算变量