Ste*_*ted 5 r ggplot2 gganimate
我想并排或至少在同一个文档中显示由 gganimate 包制作的动画。
使用的绘图:
library(ggplot2)
library(gganimate)
anime_one <-
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
# Here comes the gganimate code
transition_states(
gear,
transition_length = 2,
state_length = 1
) +
enter_fade() +
exit_shrink() +
ease_aes('sine-in-out')
anime_two <-
ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(cyl))) +
geom_boxplot() +
# Here comes the gganimate code
transition_states(
gear,
transition_length = 2,
state_length = 1
) +
enter_fade() +
exit_shrink() +
ease_aes('sine-in-out')
Run Code Online (Sandbox Code Playgroud)
第一次尝试:
library(patchwork)
anime_one + anime_two
Error in UseMethod("ggplot_gtable") :
no applicable method for 'ggplot_gtable' applied to an object of class
"gganim_built"
Run Code Online (Sandbox Code Playgroud)
第二次尝试:
library(patchwork)
animate(anime_one+anime_two)
Run Code Online (Sandbox Code Playgroud)
这实际上渲染并且不会给出错误,但结果是只有最后一个“gganim_built”对象的动画(这里是anime_two)
第三次尝试(有效,但不是我真正想要的)
我发现的唯一半途而废的解决方案是将所有内容都包含在 Rmarkdown 文档中,然后使用动画调用制作编解码器(只有一个动画调用 pr codechunk 否则它不起作用) ),最后将文档编织成 HTML:
```{r}
animate(anime_one)
```
```{r}
animate(anime_two)
```
Run Code Online (Sandbox Code Playgroud)
有没有人设法让 gganimate 对象并排出现?
提前致谢。
似乎正在重写 gganimate 帮助文档,也许您可以在此处找到有关“动画合成”的解决方案:
https://github.com/thomasp85/gganimate/wiki/Animation-Composition
在“与魔法并排放置动画”的标题下,有一种方法可以做到这一点。希望这有帮助
| 归档时间: |
|
| 查看次数: |
3022 次 |
| 最近记录: |