Skip to content
Prev 37935 / 63424 Next

strange interaction between rasterImage and Grid graphics

Hi
baptiste auguie wrote:
>
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.
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.

Paul