A search on "make animated plots in R" brought up many hits and the
gganimate package (and maybe others, as I didn't scroll through).

Bert

On Fri, Mar 22, 2024, 18:45 Bickis, Mikelis <bic...@math.usask.ca> wrote:

> Hello:
>
> I want to present a sequence of plots as an animation.   As a toy example
> consider the code
>
> function(n){for (i in 1:n){
> plot(1:100,sin(i*(1:100)),type="l")
> title(paste("n=",i))
> segments(0,0,100,0,col=2)
> }}
>
> This sort-of works on a MacOS platform, but the rendering of the plots is
> a bit choppy.  Inserting a sleep function allows the plots to evolve
> smoothly.
>
> function(n){for (i in 1:n){
> plot(1:100,sin(i*(1:100)),type="l")
> title(paste("n=",i))
> segments(0,0,100,0,col=2)
> Sys.sleep(.2)
> }}
>
> However, on a Windows platform, only the last plot is rendered without the
> Sys.sleep, so the dynamic element is lost.   Inserting the Sys.sleep does
> allow all the plots to be rendered, but they seem to be erased before they
> are drawn again, so there is substantial flicker in the appearance.
>
> Is there some kind of double-buffering available within R, so that plots
> are rendered only after they are fully drawn, leaving the previous plot
> visible until it is replaced?   I just used the default graphics driver on
> Windows — is there perhaps a different driver that will the graphics
> smoother?
>
> Mik Bickis
> Professor Emeritus
> Department of Mathematics and Statistics
> University of Saskatchewan
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to