| thigmophobe.labels {plotrix} | R Documentation |
thigmophobe.labels places labels adjacent to each point,
offsetting each label in the direction returned by
thigmophobe.
thigmophobe.labels(x,y,labels=1:length(x),...)
x,y |
Numeric data vectors. Typically the x/y coordinates of plotted points. |
labels |
A vector of strings that will be placed adjacent to each point. Defaults to the indices of the coordinates. |
... |
additional arguments are passed to text |
.
Typically used to automatically place labels on a scatterplot or similar to avoid overlapping labels.
A vector of directions away from the point nearest to each point.
Jim Lemon
x<-rnorm(10)
y<-rnorm(10)
xlim<-range(x)
xspace<-(xlim[2]-xlim[1])/20
xlim<-c(xlim[1]-xspace,xlim[2]+xspace)
ylim<-range(y)
yspace<-(ylim[2]-ylim[1])/20
ylim<-c(ylim[1]-yspace,ylim[2]+yspace)
plotlabels<-
c("one","two","three","four","five","six","seven","eight","nine","ten")
plot(x=x,y=y,xlim=xlim,ylim=ylim,main="Test thigmophobe.labels")
# skip the almost invisible yellow label
thigmophobe.labels(x,y,plotlabels,col=c(2:6,8:12))