x <- 1:100
y <- sin(8*pi*x/100)
chr <- rep(1, length(x))
indexes <- getSegments(y, chr, cutoff=0.8)
plot(x, y, type="n")
for(i in 1:3){
ind <- indexes[[i]]
for(j in seq(along=ind)) {
k <- ind[[j]]
text(x[k], y[k], j, col=i)
}
}
abline(h=c(-0.8,0.8))
Run the code above in your browser using DataLab