[R] Line Graph Labels

Walmes Zeviani walmeszeviani at hotmail.com
Thu Apr 1 22:34:33 CEST 2010


You can set the number of extreme points to be labeled instead of define a
cutoff. Look:

da <- data.frame(y=rnorm(50), x=1:50)
plot(y~x, data=da)
abline(h=c(-2,2), lty=3)
with(da, text(x[abs(y)>2], y[abs(y)>2], label=x[abs(y)>2], pos=2))

da <- da[order(da$y),]
plot(y~x, data=da)
# five small and big numbers
num <- 5
with(da, points(x[c(1:num, nrow(da):(nrow(da)-num))],
                y[c(1:num, nrow(da):(nrow(da)-num))], pch=3, col=2))
with(da, text(x[c(1:num, nrow(da):(nrow(da)-num))],
              y[c(1:num, nrow(da):(nrow(da)-num))],
              label=x[c(1:5,nrow(da):(nrow(da)-5))], pos=rep(c(1,3),
each=num)))

Hope that helps.
Walmes.

-----
..ooo0
...................................................................................................
..(....)... 0ooo...                              Walmes Zeviani
...\..(.....(.....)...     Master in Statistics and Agricultural
Experimentation
....\_)..... )../....       walmeszeviani at hotmail.com, Lavras - MG, Brasil
............
(_/............................................................................................
-- 
View this message in context: http://n4.nabble.com/Line-Graph-Labels-tp1748218p1748558.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list