Place labels away from the nearest point
thigmophobe.labels places labels adjacent to each point, offsetting each label in the direction returned by thigmophobe.
- Numeric data vectors or a list with two components. Typically the x/y coordinates of plotted points.
- A vector of strings that will be placed adjacent to each point. Defaults to the indices of the coordinates.
- An optional vector of text positions (see text).
- additional arguments are passed to text
Typically used to automatically place labels on a scatterplot or
similar to avoid overlapping labels. thigmophobe.labels
will sometimes place a label off the plot or fail to separate
labels in clusters of points. The user can manually adjust the
errant labels by running thigmophobe first and saving
the returned vector. Then modify the position values to place
the labels properly and pass the edited vector to
thigmophobe.labels as the text.pos argument. This
takes precedence over the positions calculated by thigmophobe.
Both pointLabel in the
- A vector of directions away from the point nearest to each point.
x<-rnorm(20) y<-rnorm(20) xlim<-range(x) xspace<-(xlim-xlim)/20 xlim<-c(xlim-xspace,xlim+xspace) ylim<-range(y) yspace<-(ylim-ylim)/20 ylim<-c(ylim-yspace,ylim+yspace) plotlabels<- c("one","two","three","four","five","six","seven","eight","nine","ten", "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen", "eighteen","nineteen","twenty") plot(x=x,y=y,xlim=xlim,ylim=ylim,main="Test thigmophobe.labels") # skip the almost invisible yellow label, make them bold and without borders thigmophobe.labels(x,y,plotlabels,col=c(2:6,8:12),border=NA,font=2)