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

From: <vincent_at_7d4.com>
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 ?



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.