[R] clipping viewports

Paul Murrell paul at stat.auckland.ac.nz
Mon Oct 1 08:42:33 CEST 2007


Hi


Mikkel Grum wrote:
> Dear useRs,
> 
> Why are the rotated blue and yellow boxes in the example below clipped outside of 6 x 6 inch window in the middle of the page?? Where does the 6 x 6 inch window come from? I would like to make use of the entire page.


6x6 corresponds to the default size of the pdf() device, so it looks 
like an issue with the implementation of paper="a4".  Indeed, this 
variation works as expected for me ...

pdf(file = "FarmMaps.pdf", width=7.6, height=11)

I will look at why the original approach does not work.

Paul


>> library(grid)
>> pdf(file = "FarmMaps.pdf", paper = "a4")
>> pushViewport(viewport(
> +    width = unit(7.6, "inches"), height = unit(11, "inches"), clip = "off"))
>> grid.rect(gp = gpar(col = NA, fill = "grey"))
>> pushViewport(viewport(x = unit(3.6, "inches"), y = unit(3.6, "inches"),
> +    width = unit(3.6, "inches"), height = unit(3.6, "inches"), clip = "off",
> +    angle = 76))
>> grid.rect(gp = gpar(col = NA, fill = "blue"))
>> upViewport()
>> pushViewport(viewport(x = unit(1.8, "inches"), y = unit(7.6, "inches"),
> +    width = unit(2.6, "inches"), height = unit(2.6, "inches"), clip = "off",
> +    angle = -56))
>> grid.rect(gp = gpar(col = NA, fill = "yellow"))
>>
>> dev.off()
> null device 
>           1 
>> sessionInfo()
> R version 2.5.1 (2007-06-27) 
> i386-pc-mingw32 
> 
> locale:
> LC_COLLATE=English_Ireland.1252;LC_CTYPE=English_Ireland.1252;LC_MONETARY=English_Ireland.1252;LC_NUMERIC=C;LC_TIME=English_Ireland.1252
> 
> attached base packages:
> [1] "grid"      "stats"     "graphics"  "grDevices" "utils"     "datasets" 
> [7] "methods"   "base" 
>     > 
> 
> Any assistance greatly appreciated,
> Mikkel
> 
> 
> 
>        
> ____________________________________________________________________________________
> Pinpoint customers who are looking for what you sell. 
> http://searchmarketing.yahoo.com/
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
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/



More information about the R-help mailing list