bil*_*999 3 r render ggplot2 gganimate
我正在使用 ggplot2+gganimate+ggflags 制作绘图,但渲染速度非常慢:通常每秒 0.1 帧或低于 0.1 帧。因此,如果我有 300 帧,则需要很长时间。我注意到是 ggflags 导致它变得比其他方式慢得多。我可以做些什么来加快渲染速度?我正在使用 MacBook Pro。
我非常基本的代码设置如下所示:
plot <- data %>% ggplot2(aes(...)) + geom_flag(...) + lots of options + transition_time(year)
anim_save("file.gif", plot, ...)
Run Code Online (Sandbox Code Playgroud)
如果没有具体的例子,很难给出明确的答案。
当我运行以下命令时,它在我的 2012 macbook air 上产生大约 3.5 fps。随着geom_point
到位的geom_flag
,它产生约4.5 fps的。考虑到标志绘制起来更复杂,这并没有让我觉得这是一个特别大的放缓。您是否有其他选项或很多标志可能会使其变慢?
library(tidyverse)
library(ggflags) # Using v0.0.1 downloaded 11/30/19 from
# https://github.com/ellisp/ggflags
library(gganimate)
library(gapminder)
animate(
gapminder %>%
filter(continent == "Asia") %>%
ggplot(aes(gdpPercap, lifeExp, country = country)) +
geom_flag() +
transition_time(year),
width = 700, height = 400, fps = 20)
Run Code Online (Sandbox Code Playgroud)