[R] label points on a graph

Jim Lemon
2008-06-09T08:13:33Z

Paul Adams wrote:
> Hello everyone,
> I have a plot and I am wanting to label points as 1 through 20
> I have the following code for the plot:
> dat<-read.table(file="C:\\Documents and Settings\\Owner\\My
Documents\\colon cancer1.txt",header=T,row.names=1)
> file.show(file="C:\\Documents and Settings\\Owner\\My Documents\\colon
cancer1.txt")
>
plot(dat[1:20,1:2],type='p',xlab='normal1',ylab='normal2',main='Two
normal samples--first 20 genes',pch=15,col='blue')
> grid(nx=5,ny=5,col="black",lty="dotted",lwd=2)
> Do I use the label function text(x,y,names)? If so do I specify to put 1-20
above the points as text(5,5,1:20,pos=3)?
> Any help would be much appreciated

Hi Paul,
The "thigmophobe.labels" function in the plotrix package is intended
for
this sort of labeling. As well as placing a label adjacent to each
point, it offsets each label away from the nearest point. This avoids
overlapping labels when two or three points are close together. You can
also tweak the positioning manually if need be.

Jim