[R] text position with offset
murdoch.duncan at gmail.com
Thu Oct 3 21:16:53 CEST 2013
On 03/10/2013 12:48 PM, Jinsong Zhao wrote:
> Hi there,
> I have draw a scatter plot. Now, I hope to label the points in the plot.
> For example:
> text(1:10, 1:10, LETTERS[1:10])
> In the above line, I can set position for each labels with pos, e.g.:
> text(1:10, 1:10, LETTERS[1:10], pos = sample(1:4, 10, replace = TRUE))
> as what you have seen, the length of pos can be longer than 1. in the
> above case, it has the length 10.
> However, I can not set offset with length longer than 1. The following
> code always set the offset to 0.1 rather than 0.1, 0.2, ..., 1 for the
> 10 labels.
> text(1:10, 1:10, LETTERS[1:10], pos = sample(1:4, 10, replace = TRUE),
> offset = seq(0.1, 1, 0.1))
> it seems that adj also can not be set for multiple points with different
> Any hints? Thanks in advance.
See ?text: those parameters apply to all text. To get what you want,
call text() 10 times (e.g. in a loop, or in lapply).
More information about the R-help