File: corner.label.R

package info (click to toggle)
r-cran-plotrix 3.2-6-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,136 kB
  • sloc: makefile: 3
file content (24 lines) | stat: -rwxr-xr-x 674 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
corner.label<-function(label=NULL,x=-1,y=1,xoff=NA,yoff=NA,figcorner=FALSE,...) {

 if(is.na(xoff)) xoff<-strwidth("m")/2
 if(is.na(yoff)) yoff<-strheight("m")/2
 par.usr<-par("usr")
 xpos<-par.usr[(3+x)/2]
 ypos<-par.usr[(3+y)/2+2]
 if(figcorner) {
  par.pin<-par("pin")
  xplotrange<-par.usr[2]-par.usr[1]
  yplotrange<-par.usr[4]-par.usr[3]
  par.mai<-par("mai")
  xmar<-xplotrange*par.mai[3+x]/par.pin[1]
  ymar<-yplotrange*par.mai[2+y]/par.pin[2]
  xpos<-xpos+x*xmar
  ypos<-ypos+y*ymar
 }
 if(!is.null(label)) {
  if(figcorner) par(xpd=TRUE)
  text(xpos-x*xoff,ypos-y*yoff,label,adj=c((1+x)/2,(1+y)/2))
  if(figcorner) par(xpd=FALSE)
 }
 return(list(x=xpos,y=ypos))
}