Re: [R] Help with coloring segments on a plot

From: Jim Lemon <>
Date: Tue, 03 May 2011 19:02:27 +1000

On 05/03/2011 04:26 AM, Paul Davison wrote:
> Hi. I need a very short piece of help regarding colouring segments plotted
> on a graph.
> When I am plotting segments for the graph, I am using "red" and "darkgreen
> for the values "1" and "2" respectively. Heres the relevant line of code in
> R:
Hi Paul,
Try this simple bit of code and see if it contains the elements you need to solve the problem.

# grab a bunch of easily distinguishable colors linecolors<-col2rgb(c(1:6,"#8888dd","brown","orange","pink")) # make an empty plot
# plot segments with the colors
segments(1:10,0:9,2:11,1:10,col=linecolors) # stick some points on to better see the colors points(1:10,0:9,pch=19,col=linecolors)

Jim mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 05 May 2011 - 06:25:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 07:00:06 GMT.

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

list of date sections of archive