Skip to content

Help with coloring segments on a plot

3 messages · Paul Davison, Andrew Robinson, Jim Lemon

#
Hi Paul,

not to seem naive, but have you actually tried the code below?  It
doesn't seem that you have, from your text.  I think that if you try
it and hack then ask concrete questions (e.g. can anyone explain why
the following simple, reproducible, commented code does not work) then
you'll have more luck.

Best wishes

Andrew
On Mon, May 02, 2011 at 02:26:16PM -0400, Paul Davison wrote:

  
    
#
On 05/03/2011 04:26 AM, Paul Davison wrote:
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(0:10,type="n")
# 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