Re: [R] Colour-coding intervals on a line

From: <>
Date: Sat 12 Aug 2006 - 16:32:45 EST

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 ? mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sat Aug 12 16:35:58 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 12 Aug 2006 - 18:18:17 EST.

Mailing list information is available at Please read the posting guide before posting to the list.