【发布时间】:2018-02-08 10:47:06
【问题描述】:
我有一个需要实时重新绘制为视频的数据集。 1 秒内有 1000 个数据点。在此之后,我还想以 1/10 的速度重新绘制相同的视频。一个例子如下所示。我在另一个软件中执行此操作,该软件可以选择在 GUI 界面中执行此操作。
有没有办法在 R 或 Python 中做到这一点?我查看了一些库,例如 R 中的“动画”,但无法得到我想要的。
【问题讨论】:
标签: python r animation video plot
我有一个需要实时重新绘制为视频的数据集。 1 秒内有 1000 个数据点。在此之后,我还想以 1/10 的速度重新绘制相同的视频。一个例子如下所示。我在另一个软件中执行此操作,该软件可以选择在 GUI 界面中执行此操作。
有没有办法在 R 或 Python 中做到这一点?我查看了一些库,例如 R 中的“动画”,但无法得到我想要的。
【问题讨论】:
标签: python r animation video plot
这是一个在 R 中使用 animation 包的示例:
library(animation)
set.seed(2)
dat = data.frame(x=1:50, y=cumsum(rnorm(50)))
# Two times through the animation, once fast, once slow
ani.options(interval=rep(c(1/nrow(dat),1/nrow(dat)*10), each=nrow(dat)))
saveGIF(for(i in 1:(2*nrow(dat))) {
plot(dat$x[1:(i %% nrow(dat))], dat$y[1:(i %% nrow(dat))], type="l",
ylim=range(dat$y), xlim=range(dat$x), xlab="Time", ylab="Value")
}, "my_movie.gif")
【讨论】: