[Rd] strange interaction between rasterImage and Grid graphics
Deepayan Sarkar
deepayan.sarkar at gmail.com
Sun Oct 3 07:36:07 CEST 2010
On Sat, Oct 2, 2010 at 4:35 PM, Paul Murrell <p.murrell at auckland.ac.nz> wrote:
> Hi
>
> baptiste auguie wrote:
>>
>> Dear all,
>>
>> This may be specific to Mac, I haven't had a chance to test another
>> platform. Consider this,
>>
>> plot(1,1,t="n")
>> rasterImage(matrix(1),1,1,1,1)
>> library(grid)
>> grid.rect(gp=gpar(fill="grey"))
>
>>
>>
>> The grid.rect covers the full device window as expected. However, when
>> I resize the window ever so slightly (interactive device) the rectGrob
>> is suddenly clipped to the previous plot window. I cannot understand
>> this behavior, and it doesn't happen if one removes the rasterImage()
>> call, so I suspect something iffy is going on with the display list or
>> something.
>
> It happens like this:
>
> # 1. Clip to the device and draw axes and labels
> plot(1,1,t="n")
> # 2. Clip to the plot region and draw raster
> rasterImage(matrix(1),1,1,1,1)
> library(grid)
> # Oooh! This is the first time any grid drawing
> # has occurred on the device, so initialize grid
> # stuff, including the top-level viewport,
> # *which clips to the device*
> # 3. Draw a rectangle
> grid.rect(gp=gpar(fill="grey"))
>
> # Resize the window ...
> # which triggers a redraw ...
> # Oooh! There is grid output on this device so
> # initialize grid stuff, including the top-level
> # viewport *which clips to the device* ...
> # 1. Clip to the device and draw axes and labels
> # 2. Clip to the plot region and draw raster
> # 3. Draw a rectangle
>
> A workaround is to explicitly do a clip before the grid.rect(), i.e., ...
>
> plot(1,1,t="n")
> rasterImage(matrix(1),1,1,1,1)
> library(grid)
> grid.clip()
> grid.rect(gp=gpar(fill="grey"))
>
> ... and I will add this example to the things I will look at when I am
> trying to clean up the grid code a bit.
>
>> The only device I've tried is quartz(), x11() crashed with rasterImage,
>
> That is more serious. I have heard of a couple of others like this and I
> think the common thread may be 64-bit MacOS X. I need to get access to such
> a beast to take a look.
Or maybe just 64 bit. I have (running Debian unstable)
> sessionInfo()
R version 2.12.0 Under development (unstable) (2010-09-02 r52864)
Platform: x86_64-unknown-linux-gnu (64-bit)
and I get reproducible crashes (same 'memory not mapped' segfault) with
x11(type="Xlib")
example(rasterImage) #or
library(lattice)
example(panel.levelplot.raster)
[I noticed this a while back, but neglected to report.]
-Deepayan
>
> Paul
>
>> *** caught segfault ***
>> address 0x28, cause 'memory not mapped'
>>
>> Traceback:
>> 1: rasterImage(matrix(1), 1, 1, 1, 1)
>>
>> sessionInfo()
>> R version 2.11.1 (2010-05-31)
>> x86_64-apple-darwin9.8.0
>>
>> locale:
>> [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
>>
>> attached base packages:
>> [1] grid stats graphics grDevices utils datasets methods
>> base
More information about the R-devel
mailing list