4

I would like to plot some values that I calculate continously. I prepared a litte code example to explain this problem. Every time, I create a new value, I would like to insert this into my plot and update the diagram.

library('ggplot2')

x <- seq(1,20)
y <- rnorm(20)

g <- qplot(x, y)

for(i in 1:50){
    y <- c(y[2:20], rnorm(1))
    print(g)
}

So the example works but it flickers tremendously, every time a new diagram is created, it gets cleared (a white screen) and after some time and only for a short period the diagram appears.

If I use only the standard plot(x,y) it works perfect but I would like to apply ggplot. Or do I have to change the parameters of X11() or maybe there is a faster device, or maybe ggplot has some kind of update function (only updating the points)?

4

0 回答 0