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

Erik Iverson iverson at biostat.wisc.edu
Wed Feb 13 19:59:49 CET 2008

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

## 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

## 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)


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

More information about the R-devel mailing list