Re: [Rd] strange interaction between rasterImage and Grid graphics
On Sat, Oct 2, 2010 at 4:35 PM, Paul Murrell 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] strange interaction between rasterImage and Grid graphics
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. 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 __ R-devel@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 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] strange interaction between rasterImage and Grid graphics
Hi, Thanks for the follow-up. On 2 October 2010 09:33, Deepayan Sarkar wrote: > On Fri, Oct 1, 2010 at 12:17 AM, 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. > > I can reproduce the behaviour on GNU/Linux x11(type="cairo"), but this > is inappropriate mixing of base and grid graphics, so officially I > don't think you are allowed to expect anything at all. > I think the gridBase package does this kind of mixing of base and grid graphics; and also this behavior might be a side-effect of a more serious bug. Best regards, baptiste > -Deepayan > > >> >> The only device I've tried is quartz(), x11() crashed with rasterImage, >> >> *** 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 >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Eval and the enclos argument
On 02/10/2010 10:40 AM, Hadley Wickham wrote: On Sat, Oct 2, 2010 at 8:18 AM, Duncan Murdoch wrote: On 02/10/2010 7:57 AM, Hadley Wickham wrote: Hi all, I'm trying to understand the default value of the enclos argument of eval: enclos = if(is.list(envir) || is.pairlist(envir)) parent.frame() else baseenv() Why isn't it just enclos = parent.frame() given that enclos is only meaningful (given my reading of the documentation) when envir is not an environment already. Hadley I think that handles the case of envir=NULL. So that makes eval(expr, NULL) equivalent to eval(expr, baseenv()), right? I think so. Duncan __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Eval and the enclos argument
On Sat, Oct 2, 2010 at 8:18 AM, Duncan Murdoch wrote: > On 02/10/2010 7:57 AM, Hadley Wickham wrote: >> >> Hi all, >> >> I'm trying to understand the default value of the enclos argument of eval: >> >> enclos = if(is.list(envir) || is.pairlist(envir)) parent.frame() >> else baseenv() >> >> Why isn't it just >> >> enclos = parent.frame() >> >> given that enclos is only meaningful (given my reading of the >> documentation) when envir is not an environment already. >> >> Hadley >> > > > I think that handles the case of envir=NULL. So that makes eval(expr, NULL) equivalent to eval(expr, baseenv()), right? Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Eval and the enclos argument
On 02/10/2010 7:57 AM, Hadley Wickham wrote: Hi all, I'm trying to understand the default value of the enclos argument of eval: enclos = if(is.list(envir) || is.pairlist(envir)) parent.frame() else baseenv() Why isn't it just enclos = parent.frame() given that enclos is only meaningful (given my reading of the documentation) when envir is not an environment already. Hadley I think that handles the case of envir=NULL. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Eval and the enclos argument
Hi all, I'm trying to understand the default value of the enclos argument of eval: enclos = if(is.list(envir) || is.pairlist(envir)) parent.frame() else baseenv() Why isn't it just enclos = parent.frame() given that enclos is only meaningful (given my reading of the documentation) when envir is not an environment already. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] strange interaction between rasterImage and Grid graphics
On Fri, Oct 1, 2010 at 12:17 AM, 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. I can reproduce the behaviour on GNU/Linux x11(type="cairo"), but this is inappropriate mixing of base and grid graphics, so officially I don't think you are allowed to expect anything at all. -Deepayan > > The only device I've tried is quartz(), x11() crashed with rasterImage, > > *** 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 > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel