[R] Resize Graphics Window

Sigal Blay sblay at sfu.ca
Mon May 3 02:55:34 CEST 2010

Here's a simplified code example.

vp1 <- viewport(height=0.8, width=0.8, default.unit="snpc")
vp2 <- viewport(y = 0.5, just="bottom", gp=gpar(col="red", lwd="2"))

# draw triangle
function1 <- function(vp) {
  grid.polygon(x=c(0,0.5,1), y=c(0.5,0,0.5), name="triangle", vp=vp)

# draw n horizontal lines above the triangle
function2 <- function(n, vp) {
   vp2$height <- unit(n*0.2, "npc")
   for (i in 1:n)
     grid.lines(x=c(0,1), y=c(i*0.2, i*0.2), vp=vp)

function2(5, vp2)  # User needs to draw 5 lines above triangle

----- Original Message -----
From: "Tal Galili" <tal.galili at gmail.com>
To: "Sigal Blay" <sblay at sfu.ca>
Cc: r-help at r-project.org
Sent: Saturday, May 1, 2010 11:48:43 PM GMT -08:00 US/Canada Pacific
Subject: Re: [R] Resize Graphics Window

Hi Sigal, could you give a simple example ? 

I can imagine in some cases that enlarging the windows would help, but on others there are other parameters you would like to play with instead. So having an example to solve, will help people help you. 


----------------Contact Details:------------------------------------------------------- 
Contact me: Tal.Galili at gmail.com | 972-52-7275845 
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) 

On Sat, May 1, 2010 at 7:40 AM, Sigal Blay < sblay at sfu.ca > wrote: 

Need way to resize an existing graphics window. 
This should be applicable across platforms (as part of a package). 
Context: function1() draws main plot (I'm using grid), function2() adds smaller plot 
above main plot, but this one can sometimes overflow the original graphics window 


R-help at r-project.org mailing list 
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list