[Rd] removing last piece of grid graphical output with grid.remove
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Feb 13 22:36:26 CET 2008
On Thu, 14 Feb 2008, Paul Murrell wrote:
> 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.
The source is the behaviour of grid.newpage. I think you are expecting it
to clear the plot, but it doesn't (although a subsequent refresh will).
Here's a simpler example
library(grid)
grid.circle(name = "redcircle", r = .20, gp = gpar(col = "red"))
grid.newpage()
or in old money
plot(1:10)
plot.new()
As I suggested to Paul privately, it is a missing XSync call (and in fact
the second one I have found today). Will be fixed in R-patched shortly.
>
> 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
>
>
--
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
More information about the R-devel
mailing list