[R] any way to set X11() device geometry (screen offsets)?

Chris Marshall chrism at norcomnetworks.com
Tue May 29 15:54:15 CEST 2001


 I just knew that had to be a way to do what you describe in X outside of R.

What you have described is perfect.  Thanks!

Chris Marshall

-----Original Message-----
From: B.Rowlingson at lancaster.ac.uk
To: Thomas Lumley
Cc: Chris Marshall; 'r-help at stat.math.ethz.ch'
Sent: 5/29/01 8:19 AM
Subject: Re: [R] any way to set X11() device geometry (screen offsets)?

Thomas Lumley wrote:

> It doesn't look as though this would be too hard to add. We currently
put
> the lower right corner of the window 10 pixels from the lower right
corner
> of the screen, but it could be made configurable (like the width and
> height). I can't actually experiment at the moment, since I'm on the
wrong
> operating system.
> 

 If you cant wait for the next release of R to do this, then get the
really rather useful 'xwit' tool from ftp.x.org or a local mirror. 
It lets you position and size windows after they've been created, 
as well as several other things.

You need to get the window name of R graphics windows - run xwininfo
and click on an R graphics window and you should see something like:

xwininfo: Window id: 0x2c00002 "R Graphics: Device 2 (ACTIVE)"

and using xwit you can set its geometry exactly with:

xwit -move 200 200 -resize 640 200 -names "R Graphics: Device 2
(ACTIVE)"

You can then bung this into a function to pop up 9 windows and then call
xwit to put them in the right place:


x9_function(){
  
for(i in 1:9){
 x11()
}
for(i in 1:9){
 # compute position and size for window i
 args<-windowsizepos(i)
 # window name
 if(i==9){state<-"ACTIVE"}else{state<-"inactive"}
 name<- paste("\"R Graphics: Device ",i+1," (",state,")\"",sep='')
 system(paste("./xwit ",args," -names ",name,sep=''))
 }
}

 You need to write the windowsizepos(i) function to return a string like
this:

> windowsizepos(1)
[1] "-move 20 20 -resize 200 200"

 that gives the right position and size for the i-th window.

 It might be worth taking the code that repositions the windows and
putting
that in a separate function, so you can easily put the windows back in
the 
default place once the user has mucked with them. You might also be able
to
use the dev. functions to figure out which is the active window so you
can 
insert 'ACTIVE' or 'inactive' in the window name.

 Hours of fun.

Barry Rowlingson
Maths and Stats
Lancaster University
Lancaster, UK
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list