[R] How to add label to lines()

David Winsemius dwinsemius at comcast.net
Wed Jun 22 16:43:12 CEST 2011


On Jun 21, 2011, at 10:31 AM, Nevil Amos wrote:

> I am plotting a number of lines on a standard plot.  I would like to  
> add labels at the end (rhs) of each line.  is there a way to do this  
> other than defining the individual xy coordinates and placing each  
> label using text()

Without an example it is difficult to know if your coding is  
efficient. The text fn is vectorized, so there may be a one-liner that  
does what you could be currently doing piecemeal.

plot(1,1)
  for( b in 1-(1:5)/20) abline(a=0,b=b)
  text(1.4, 1.4*(1-(1:5)/20), as.character(1-(1:5)/20) )


-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list