Skip to content
Prev 309816 / 398506 Next

lines with colored segments

On 12-11-04 8:29 AM, David Stevens wrote:
You might be the first to want to do this.  It's a fairly strange plot: 
  you have a category determined by the pair x[i] and x[i+1].

I think the only way to do this would be to draw the segments in a loop. 
  For example,

x <- 1:10
y <- 1:10
plot(x, y) # draw the points, in black
col <- rainbow(9)
for (i in 1:9) # draw the segments in colour
   lines(x[i:(i+1)], y[i:(i+1)], type='c', col=col[i])

Duncan Murdoch