python - 将图表重新绘制为视频

标签 python r animation video plot

我有一个数据集,需要实时重新绘制为视频。 1秒内有1000个数据点。此后,我还想以 1/10 的速度重新绘制相同的视频。一个例子如下所示。我在另一个软件中执行了此操作,该软件可以选择在 GUI 界面中执行此操作。

Actual signal in real time

Slowed down graph - 1/10th speed of actual signal

有没有办法在 R 或 Python 中做到这一点?我研究了一些库,比如 R 中的“动画”,但无法得到我想要的东西。

最佳答案

这是一个使用 animation 包的 R 示例:

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")

enter image description here

关于python - 将图表重新绘制为视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45965180/

相关文章:

r - 动态创建函数和表达式

r - 将前一行值乘以常数 R

css - 从 0 不透明度交错淡入 div

python - Python 中出现奇怪的语法解析错误?

python - 无法在 django admin 上发布 - 无法将字节连接到字符串

python - 如何用两种颜色绘制imshow?

r - 在 R 中创建索引图表 - 相对起点

html - 为什么我的动画元素不居中?

javascript - velocity-react - 在组件更新后动画 scrollTop

python - 如果默认列中的行为 NaN,如何从数据框中的其他列中选择行?