r - 渲染图像时出现 gganimate 错误
问题描述
我已经在RStudio 社区留言板上发布了这个,但没有得到回复,所以在这里发帖寻求帮助。我正在使用以下代码来创建 gganimate:
library(tidyverse)
library(dplyr)
library(ggimage)
library(ggplot2)
library(ggrepel)
library(nflfastR)
library(gganimate)
library(ggstance)
library(zoo)
source('https://raw.githubusercontent.com/samhoppen/Fantasy-Evaluator/main/Code/Image%20themes.R')
rb_stats_final <- read_csv(url("https://raw.githubusercontent.com/samhoppen/Fantasy-Evaluator/main/Data/Animation%20Test%20Data.csv"))
all_weeks <- read_csv(url("https://raw.githubusercontent.com/samhoppen/Fantasy-Evaluator/main/Data/Animation%20Weeks%20Data.csv"))
rb_ani <- ggplot(data = rb_stats_final) +
geom_col(aes(x = tot_fpts, y = reorder(player_name, -rank), color = player_id, fill = player_id, group = player_id)) +
geom_shadowtext(aes(x = name_loc, y = reorder(player_name, -rank), label = player_name, color = player_id, group = player_id),
hjust = 1, bg.color = 'white', size = 5.5, na.rm = T, bg.r = 0.06, show.legend = FALSE) +
scale_color_manual(values = NFL_sec)+
scale_fill_manual(values = NFL_pri)+
scale_x_continuous(expand = expansion(mult = c(0, 0.05))) +
theme_FE +
labs(title = "Highest-scoring Fantasy Running Backs of the Past Decade",
subtitle = paste0("{all_weeks$week_name[as.numeric(previous_state)]}"),
caption = "Figure: @SamHoppen | Data: @nflfastR",
y = "",
x = "Total Fantasy Points")+
theme(legend.position = "none",
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.line = element_line(color = 'black', size = 1.5)) +
transition_states(week_order, transition_length = 2, state_length = 1) +
view_follow(fixed_y = T) +
enter_fly(y_loc = -21) +
exit_fly(y_loc = -21) +
ease_aes('linear')
animation <- animate(rb_ani, nframes = 340, fps = 5)
但是,每当我运行最后一个 animate() 代码时,都会出现以下错误:
Warning messages:
1: Cannot get dimensions of plot table. Plot region might not be fixed
2: attempt to apply non-function
3: attempt to apply non-function
4: attempt to apply non-function
5: attempt to apply non-function
然后,当我尝试保存它时,我只得到一个空白 gif。我尝试更改字幕,在 scale_x_continuous 中添加特定的中断,并且不保持 y 轴静止,但这些都不起作用。任何有关如何解决此问题的建议都会很棒!
解决方案
推荐阅读
- python - yum update failed "StopIteration" hdr = idx.next()
- python - Launch TkInter GUI using Watchdog event
- scala - 如何根据 Spark 中的所有内容进行过滤?
- arrays - 基于角度html循环内的数组值循环项目
- laravel - Laravel + Vue: button and modal component not show up in blade
- jakarta-ee - Execute Java petstore 1.1.2 using JDK1.8
- mendeley - 带有单页应用程序的 Mendeley Web Importer
- javascript - 转换同一行上特定类的所有元素
- ansible - ansible/jinja2 how to get dict from list of merged dicts
- jenkins - 使用 Jenkins 共享库,从 vars/? 中的文件导入类?