File: thigmophobe.labels.R

package info (click to toggle)
r-cran-plotrix 3.8-14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,584 kB
  • sloc: makefile: 6
file content (20 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
thigmophobe.labels<-function(x,y,labels=NULL,text.pos=NULL,...) {
 if(missing(x)) stop("Usage: thigmophobe.labels(x,y,labels=1:length(x))")
 lenx<-length(x)
 if(missing(y)) {
  if(is.list(x) && lenx >= 2) {
   y<-x[[2]]
   x<-x[[1]]
  }
  else stop("if y is missing, x must be a list with at least 2 elements")
 }
 validxy<-!(is.na(x) | is.na(y))
 if(is.null(labels)) labels<-1:lenx
 if(is.null(text.pos)) {
  if(lenx > 1) text.pos<-thigmophobe(x[validxy],y[validxy])
  else text.pos<-3
 }
 par(xpd=TRUE)
 text(x[validxy],y[validxy],labels[validxy],pos=text.pos,...)
 par(xpd = FALSE)
}