使用geom_line在ggplot中创建时间序列图

5

我相对而言对gganimate并不熟悉,正在尝试在R studio上创建一个简单的多项式时间序列图。

x <- 1:100

f <- function (x){
  return(-(x)^2)
}

df <- data.frame(x, y= -(x)^2)

ggplot(df, aes(x, y)) + 
   geom_line() + 
   stat_function(fun=f) + 
   transition_states(x, transition_length = 1, state_length = 2 )

我的错误显示为:
" Error in transform_path(all_frames, next_state, ease, params$transition_length[i],  : 
  transformr is required to tween paths and lines "

我想知道transition_state()函数是否有缺失?在静态图表中看起来很好,但我想把它做成时间序列图。非常感谢任何建议/帮助!谢谢!

transition_states 是从哪里来的?请编辑问题并调用 library(pkgname) 加载包含 transition_states 的软件包。 - Rui Barradas
1个回答

7

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接