Erik Iverson
2008-Feb-13 18:59 UTC
[Rd] removing last piece of grid graphical output with grid.remove
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
Paul Murrell
2008-Feb-13 19:25 UTC
[Rd] removing last piece of grid graphical output with grid.remove
Hi Erik Iverson wrote:> 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?I've seen this type of behaviour on X11 before, but I think it is specific to that device (e.g., you get the "right" behaviour on Windows). I have not yet attempted to seek out the source of the X11 problem. Paul> ## 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 > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel-- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/