[R] Windows, OSX and Linux: updating a graphic device and double buffering

Yihui Xie xie at yihui.name
Sun Jan 23 22:52:39 CET 2011


I'm looking for answers to your questions as well. Has double
buffering been really implemented for Windows? I cannot find any
announcement in the NEWS or ONEWS or OONEWS file in svn, although it
looks Windows graphics devices perform much better than Linux
x11()/Mac OS quartz().

It looks the Graphics task view needs to be updated too if double
buffering is already implemented:
http://cran.r-project.org/web/views/Graphics.html

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Fri, Jun 11, 2010 at 11:28 AM, Adrian Waddell <adrian at waddell.ch> wrote:
> Hello there,
>
> I'm struggling with the base graphics system on different
> operating systems.
>
> I would like to get an animation effect by re-plotting with the plot
> function. See the attached code example: move the slider
> quick from one side to the other.
>
> I experience different levels of success, depending on which OS I use.
>
> - Linux (Ubuntu >9.10, R 2.9.2-3): Each plot command gets displayed.
> However the labels are flickering.
>
> - Windows: works perfect, double buffering is really well implemented.
>
> - OS X: Moving the slider slowly results in displaying the output of
> almost all plot commands. However if you move the slider quickly, only few
> of the plot commands get displayed (the orange bullet jumps).
>
> This question has been asked before, but hopefully things have changed: Is
> it possible to double buffer my output manually?
>
> If not, is it possible to force update my graphic device. E.g. with a
> command like dev.flush()?
>
> How can I run my code on all operating systems without any "jumps"?
>
> Regards,
>
> Adrian Waddell
>
>
> Here is a minimal example code:
>
> library(tcltk)
> tt <- tktoplevel()
> tkpack(top <- tkframe(tt), side = "top")
> SliderValue <- tclVar("50")
> SliderValueLabel <- tklabel(top,text=as.character(tclvalue(SliderValue)))
> tkpack(tklabel(top,text="Slider Value : "),SliderValueLabel, side = "left")
> tkconfigure(SliderValueLabel,textvariable=SliderValue)
> slider <- tkscale(tt, from=0, to=100,
>                showvalue=F, variable=SliderValue,
>                resolution=1, orient="horizontal", length = 200)
> tkpack(slider, side = "top")
> tkconfigure(slider, command=function(...){
>                        state <- unlist(...)
>                        myPlotFn(state)
>                })
>
> myPlotFn <- function(state) {
>        plot(1,1, type = 'n', xlim = c(-10,110), ylim = c(-2,2))
>        lines(c(0,100), c(0,0), lwd=4)
>        points(as.numeric(tclvalue(SliderValue)),0, cex = 10, pch = 19, col =
> "orange")
> }
>



More information about the R-help mailing list