Re: [R] Double buffering plots on Windows

2024-03-25 Thread Paul Murrell

Hi

I would not describe myself as a heavy user of this stuff (either 
Windows or animation) - are you able to share your examples ?


Paul

On 26/03/24 04:23, Michael L Friendly wrote:

Hi Paul

Is there a concrete working example somewhere that shows how to use 
these to do an animation on Windows (R Gui &/or RStudio) using base R 
plot() and friends?


I have several old examples somewhere that used to work (R < ~ 3), but 
now no longer work as before.





Date: Mon, 25 Mar 2024 10:43:29 +1300

From: Paul Murrell 
mailto:p...@stat.auckland.ac.nz>>


To: "Bickis, Mikelis" 
mailto:bic...@math.usask.ca>>, 
"r-help@r-project.org<mailto:r-help@r-project.org>"


mailto:r-help@r-project.org>>

Subject: Re: [R] Double buffering plots on Windows

Message-ID: 
mailto:b74c68da-a0b2-47dd-b54f-6b318488c...@stat.auckland.ac.nz>>


Content-Type: text/plain; charset="utf-8"; Format="flowed"



Hi



Take a look at dev.hold() and dev.flush()



Paul


---
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University Voice: 416 736-2100 x66249
4700 Keele Street Web: http://www.datavis.ca 
<http://www.datavis.ca><http://www.datavis.ca/ <http://www.datavis.ca/>> | @datavisFriendly

Toronto, ONT M3J 1P3 CANADA


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help 
<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html 
<http://www.R-project.org/posting-guide.html>

and provide commented, minimal, self-contained, reproducible code.


--
Dr Paul Murrell (he/him)
Te Kura Tatauranga | Department of Statistics
Waipapa Taumata Rau | The University of Auckland
Private Bag 92019, Auckland 1142, New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
www.stat.auckland.ac.nz/~paul/

__
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.


Re: [R] Double buffering plots on Windows

2024-03-25 Thread Michael L Friendly
Hi Paul

Is there a concrete working example somewhere that shows how to use these to do 
an animation on Windows (R Gui &/or RStudio) using base R plot() and friends?

I have several old examples somewhere that used to work (R < ~ 3), but now no 
longer work as before.




Date: Mon, 25 Mar 2024 10:43:29 +1300

From: Paul Murrell mailto:p...@stat.auckland.ac.nz>>

To: "Bickis, Mikelis" mailto:bic...@math.usask.ca>>, 
"r-help@r-project.org<mailto:r-help@r-project.org>"

mailto:r-help@r-project.org>>

Subject: Re: [R] Double buffering plots on Windows

Message-ID: 
mailto:b74c68da-a0b2-47dd-b54f-6b318488c...@stat.auckland.ac.nz>>

Content-Type: text/plain; charset="utf-8"; Format="flowed"



Hi



Take a look at dev.hold() and dev.flush()



Paul


---
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-2100 x66249
4700 Keele StreetWeb: http://www.datavis.ca<http://www.datavis.ca/> | 
@datavisFriendly
Toronto, ONT  M3J 1P3 CANADA


[[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.


Re: [R] Double buffering plots on Windows

2024-03-24 Thread Paul Murrell

Hi

Take a look at dev.hold() and dev.flush()

Paul

On 23/03/24 06:43, Bickis, Mikelis 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.


--
Dr Paul Murrell (he/him)
Te Kura Tatauranga | Department of Statistics
Waipapa Taumata Rau | The University of Auckland
Private Bag 92019, Auckland 1142, New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
www.stat.auckland.ac.nz/~paul/

__
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.


Re: [R] Double buffering plots on Windows

2024-03-23 Thread Bert Gunter
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  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.


[R] Double buffering plots on Windows

2024-03-22 Thread Bickis, Mikelis
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.