ggplotly facet_wrap 不在 R 中显示一些子图

ggplotly facet_wrap don't display some subplots in R

我正在尝试用 facet_wrap 制作一个 ggplot,但由于某些原因,某些子图有时不显示并且显示为空白。

library(plotly)
peak_season <- drop_na(read_csv(url("https://www.dropbox.com/s/wb8qmrcul197ypp/peak_season.csv?raw=1")))
    
ggplotly(
  ggplot(data = peak_season, aes(x = overall, frame = age)) +
    geom_bar(position = "identity") + facet_wrap(~league_name_clean)
)
# Need to add position = "identity" due to a well known bug in ggplotly and geom_bar.

如图所示,可以获取数据来制作绘图。 西班牙甲级联赛肯定有 20 岁球员的数据。

ggplotly(
  ggplot(data = peak_season %>% filter(league_name_clean == "Spain Primera Division"), aes(x = overall, frame = age)) +
    geom_bar(position = "identity") + facet_wrap(~league_name_clean)
    )
# Just added a filter

我让它与 gganimate 一起工作,但我希望我的用户能够控制和浏览显示的数据。

library(gganimate)    
ggplot(data = peak_season, aes(x = overall)) +
      geom_histogram(binwidth = 1) + facet_wrap(~league_name_clean) +
      transition_states(age, state_length = 1) +
      view_follow(fixed_y = TRUE) +
      labs(title = "Player peak age by league",
           y = "No. of players",
           subtitle = "Age: {closest_state}") 

我尝试使用 RStudio Cloud 在我的计算机中推出一个错误,但它发生了同样的事情。

知道为什么会这样吗?

谢谢,

对于将来可能会发现此问题的任何人,我认为 ggplotly 不够强大,无法管理计算如此多的图 + 每个整体 - 年龄 - 联赛的频率,所以我必须事先计算它。

t <- peak_season %>%
  select(overall, age, league_name_clean) %>%
  table() %>%
  as_tibble

ggplotly(
  ggplot(data = t, aes(x = Overall, y = Count, frame = age)) +
    scale_x_discrete(breaks = seq(40, 100, by = 5)) +
    geom_col(position = "identity") + facet_wrap(~league_name_clean)
  )