Hi,

Drawing grid graphics always takes long, I would write the images to png's and make the animation. If you use Linux I can suggest some nice tools to do this. This movie is also much more compatible with all kinds of machines. It might be that you can get your grid animation working on your own computer, but if another user has a less powerfull machine he might not have a smooth animation.

Good luck!
Paul

Unternährer Thomas schreef:
I need to make a fairly complex animated graphic and decided to use grid for it.
A very simple example of what I need:

##==============================================================================
library(grid)
grid.newpage()
pushViewport(plotViewport())
pushViewport(viewport(xscale = extendrange(c(0, 100)),
                      yscale = extendrange(c(0, 100))))
grid.xaxis()
grid.yaxis()

rectNames <- paste("r", 1:100, sep = "")
for (i in 1:100) {
  grid.rect(x = unit(sample(0:100, 1), "native"),
            y = unit(sample(0:100, 1), "native"),
            width = 0.1, height = 0.1, name = rectNames[i])
}

for (i in 1:100) {
  grid.remove(rectNames[i])
}
##==============================================================================

The problem here is that removing grid objects is very slow, at least in the way I use it. Is it possible to remove all objects at once (or to use some
technique similar to double buffering)?


A second way to do it would be to remove a viewport and all its children from
the current viewport tree. Is this possible? Example:

##==============================================================================
grid.newpage()
pushViewport(plotViewport())
pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100))))
grid.xaxis()
grid.yaxis()

pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100)),
             name = "plotVP"))
for (i in 1:100) {
grid.rect(x = unit(sample(0:100, 1), "native"), y = unit(sample(0:100, 1), "native"),
            width = 0.1, height = 0.1, name = paste("r", i, sep = ""))
}

*remove("plotVP")*??
##==============================================================================


Another approach would be to save every single plot as an image and use something like imagemagick to produce an animated gif, but I was just wondering
if it's possible by using grid only (no need to use it outside of R).

Thanks in advance

Thomas

______________________________________________
R-help@r-project.org mailing list
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-help@r-project.org mailing list
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