From iverson at biostat.wisc.edu  Wed Feb 13 19:59:49 2008
From: iverson at biostat.wisc.edu (Erik Iverson)
Date: Wed, 13 Feb 2008 12:59:49 -0600
Subject: [Rd] removing last piece of grid graphical output with grid.remove
Message-ID: <47B33E25.5090307@biostat.wisc.edu>

Hello -

If I create multiple pieces of output in grid, and use grid.remove() to
try to remove the output from the graphics device, I cannot seem to
remove the final piece of output from the device until I 'refresh' the 
graphics device by giving it focus.  The function grid.remove() does 
appear to remove the grob from the display list, however.

I noticed this when the example on page 200-201 in Paul Murrell's R 
Graphics book did not work as expected when using 
grid.remove("circles").  Can anyone replicate this?

## Example
library(grid)

## Create two circles
grid.circle(name = "redcircle",  r = .20, gp = gpar(col = "red"))
grid.circle(name = "bluecircle", r = .25, gp = gpar(col = "blue"))

## removes the blue circle
grid.remove("bluecircle")

## the red circle will be deleted from the grid display list, but
## the graphics device will still show it until I 'refresh' the
## device by giving it focus via mouse or alt+tab, or producing
## more grid output
grid.remove("redcircle") ## still on my X11 device!

## more grid output
grid.text("Now the circle is gone!", name = "txt")

## But I can't get rid of this text on the device
## until I refresh device or do another grid call
grid.remove("txt")  ## still on my X1 device!


 > sessionInfo()
R version 2.6.2 (2008-02-08)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods
[8] base



[Rd] removing last piece of grid graphical output with grid.remove
Erik Iverson