R 使用ggplot和gganimate设置动画
我正在尝试学习如何使用R 使用ggplot和gganimate设置动画,r,ggplot2,gganimate,R,Ggplot2,Gganimate,我正在尝试学习如何使用gganimate设置绘图动画,我想知道是否有人能为我遇到的问题提供一些建议。为了简化工作,我在RStudio Cloud中创建了一个新项目,安装了ggplot2、gganimate、和datasauRus软件包,并从以下位置执行此示例: 这将创建一系列.PNG文件,但我看不到动画。有些人似乎建议我可以使用“打印”功能查看它,但这也不起作用 我也无法将其导出为.GIF格式,尽管我遵循了给出的建议。具体来说,magick软件包对我不起作用(我得到了相同的错误,我的图像不是ma
gganimate
设置绘图动画,我想知道是否有人能为我遇到的问题提供一些建议。为了简化工作,我在RStudio Cloud中创建了一个新项目,安装了ggplot2
、gganimate
、和datasauRus
软件包,并从以下位置执行此示例:
这将创建一系列.PNG文件,但我看不到动画。有些人似乎建议我可以使用“打印”功能查看它,但这也不起作用
我也无法将其导出为.GIF格式,尽管我遵循了给出的建议。具体来说,magick
软件包对我不起作用(我得到了相同的错误,我的图像不是magick图像对象),当我尝试以下代码时:
p <- ggplot(datasaurus_dozen, aes(x=x,y=y)) +
geom_point() +
theme_minimal() +
transition_states(dataset,3,1) +
ease_aes()
anim <- animate(p)
anim_save("myfilename.gif",anim)
p您执行的步骤太多了:
library(datasauRus)
library(ggplot2)
library(gganimate)
p <- ggplot(datasaurus_dozen, aes(x=x,y=y)) +
geom_point() +
theme_minimal() +
transition_states(dataset,3,1) +
ease_aes()
anim_save("myfilename.gif",p)
库(datasauRus)
图书馆(GG2)
库(gganimate)
p我通过在animate()
中指定gifski_渲染器()
解决了这个问题:
库(tidyverse)
库(gganimate)
图书馆(gapminder)
g谢谢,这在RStudio Cloud上有效,尽管我在我的计算机上的版本上仍然得到相同的错误(“动画对象没有指定保存动画方法”)。R Studio Cloud似乎也很难做到这一点。
library(datasauRus)
library(ggplot2)
library(gganimate)
p <- ggplot(datasaurus_dozen, aes(x=x,y=y)) +
geom_point() +
theme_minimal() +
transition_states(dataset,3,1) +
ease_aes()
anim_save("myfilename.gif",p)