animatedPlot: Creates an animated plot function

Description Usage Arguments Details Value Examples

View source: R/animatedPlot.R

Description

Create an animated plot function from a plot function. Pass a function which generates your plots (eg plot, hist) and the maximum number of plots per second and this function returns a function which will ensure the function plots no more than plotsPerSecond times per second.

Usage

1
animatedPlot(plotFun, plotsPerSecond = 5, adapt = T)

Arguments

plotFun

a plotting function

plotsPerSecond

maximum number of plots per second

adapt

if TRUE, adapt the plotting interval to ensure plotting takes no more than half of all processing time.

Details

You then call this function instead of your original function, passing the same parameters you would pass to the original.

Value

a animated plotting function

Examples

1
2
3
4
5
6
7
8
aplot <- animatedPlot(plot, 5)
walk <- 0
xlim <- c(0,10000)
for (i in 1:9999) {
  Sys.sleep(0.001)
  walk <- c(walk, walk[i] + runif(1) - 0.5)
  aplot(seq_along(walk), walk, type="l", xlim=xlim)
}

mattdneal/longJobUtils documentation built on May 21, 2019, 12:59 p.m.