Getting several gganimate errors - plot region not fixed and attempt to apply non-function

I'm using the following code to create a 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)

However, whenever I run the last animate() code, I get the following errors:

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

Then when I try to save it, I just get a blank gif. I've tried changing the subtitle, adding specific breaks to the scale_x_continuous, and not holding the y-axis still, but none of that is working. Any suggestions on how to fix this would be great!

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.