Hi,
I know that interactive graphics aren't R's strongpoint, but I have a question for this list:
Are there any devices/packages available for R on Mac OS that let you move a single element in a plot without redrawing the whole plot?
I have a complex simulation running in R (with networks and cumulative summary stats), and I want to be able to make small updates to the graphics as the simulation runs. Each tick only a very few of the many graphics elements need to be changed. With standard R plotting this slows the simulation down excessively and 'flickers' the whole graphics window throughout.
The grid package lets you shift individual elements, but I've tried it in X11(), quartz() and Cairo() devices and in every case it still redraws whole plot. quartz() seems to be the fastest, but also the most flickery.
As a quick example of what I'm talking about, here is some code:
library(ggplot2)
qplot(1:5,1:5)
for(i in 1:30){
grid.gedit(gPath("geom_point"),x=unit((1:5/5)/i,"npc"))
}
This should shift the five points in the plot smoothly to the left, but the redrawing of the whole background etc makes it difficult to see what's going on.
Any ideas would be greatly appreciated.
Many thanks,
Peter
update graphics component without redrawing whole plot
3 messages · iuhz7j202 at sneakemail.com, Ken Knoblauch, Brian Ripley
<iuhz7j202 <at> sneakemail.com> writes:
Are there any devices/packages available for R on Mac OS that let you move a single element in a plot without redrawing the whole plot?
....
The grid package lets you shift individual elements, but
I've tried it in X11(), quartz() and Cairo()
devices and in every case it still redraws whole plot.
quartz() seems to be the fastest, but also the most flickery.
As a quick example of what I'm talking about, here is some code:
library(ggplot2)
qplot(1:5,1:5)
for(i in 1:30){
grid.gedit(gPath("geom_point"),x=unit((1:5/5)/i,"npc"))
}
This should shift the five points in the plot smoothly
to the left, but the redrawing of the whole background
Now about something like
library(ggplot2)
qplot(1:5,1:5)
for(i in 1:30){
grid.gedit(gPath("geom_point"),x=unit((1:5/5)/i,"npc"))
Sys.sleep(0.1)
}
Many thanks, Peter
Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen L?pine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html
That still redraws, and it flickers visibly on my (latest model with nVidia graphics) MacBook Air (on both quartz() and X11()). R graphics devices use an 'ink and paper' model, so it is impossible to remove (or move) elements. All you can do is repaint background on sections of the plot and redraw there. It can be done much more smoothly than that example in base graphics, at least. We expect to have a double-buffered X11 device soon (it is delayed by event-loop issues) and that will probably not flicker so visibly (the windows() device is double-buffered and does not).
On Fri, 20 Feb 2009, Ken Knoblauch wrote:
<iuhz7j202 <at> sneakemail.com> writes:
Are there any devices/packages available for R on Mac OS that let you move a single element in a plot without redrawing the whole plot?
....
The grid package lets you shift individual elements, but
I've tried it in X11(), quartz() and Cairo()
devices and in every case it still redraws whole plot.
quartz() seems to be the fastest, but also the most flickery.
As a quick example of what I'm talking about, here is some code:
library(ggplot2)
qplot(1:5,1:5)
for(i in 1:30){
grid.gedit(gPath("geom_point"),x=unit((1:5/5)/i,"npc"))
}
This should shift the five points in the plot smoothly
to the left, but the redrawing of the whole background
Now about something like
library(ggplot2)
qplot(1:5,1:5)
for(i in 1:30){
grid.gedit(gPath("geom_point"),x=unit((1:5/5)/i,"npc"))
Sys.sleep(0.1)
}
Many thanks, Peter
-- Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen L?pine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595