我正在尝试使用gganimate以下方法创建动画:
library(ggplot2)
library(ggthemes)
library(gifski)
library(gganimate)
load("covid-19-es.Rda")
casos <- ggplot(data,aes(x=Fecha))+geom_point(aes(y=casos,color="Casos"))+geom_point(aes(y=salidas,color="Salidas"))+theme_tufte()+transition_states(Fecha,transition_length=2,state_length=1)+labs(title='Day: {frame_time}')
animate(casos, duration = 5, fps = 20, width =800, height = 600, renderer=gifski_renderer())
anim_save("casos.png")
Run Code Online (Sandbox Code Playgroud)
使用的数据文件在这里。
最初我使用 geom_lines 而不是 geom_point,但这产生了一个错误:
Error in seq.default(range[1], range[2], length.out = nframes) :
'from' must be a finite number
Run Code Online (Sandbox Code Playgroud)
和
Error in transform_path(all_frames, next_state, ease, params$transition_length[i], :
transformr is required to tween paths and lines
Run Code Online (Sandbox Code Playgroud)
要么不喜欢台词,要么不喜欢台词。切换到点,并按照 gganimate 问题中的建议创建文件。但是,这会产生不同类型的错误:
Error: Provided file does not exist
Run Code Online (Sandbox Code Playgroud)
我真的无法弄清楚,因为我根本没有提供任何文件。无论如何试图保存会产生
Error: The animation object does not specify …Run Code Online (Sandbox Code Playgroud)