[R] Colour-coding intervals on a line

vincent at 7d4.com vincent at 7d4.com
Sat Aug 12 08:32:45 CEST 2006


Sara-Jane Dunn a écrit :

> I need to know if there is any way of using different colours for
> different intervals of a line on a graph. Eg. If I plot the line y=x for
> x=1:10, and split this line into 106 intervals (i.e. not a 'nice' number
> of intervals) how could I colour different intervals different colours
> without having to use segments and specify coordinates to join?
> Thanks in advance for any help!
> Sara-Jane

I think you'll have to use segments (?lines())
but it shouldn't be too complicated.

Put your line begin, line end, line color in a matrix(, ncol=106)
and call lines(...) in a for loop.

I would be happy to hear about another way to do it ?



More information about the R-help mailing list