[R] RE: Help with multicolored points in one plot

David Thibault dthibault at esperion.com
Thu Feb 26 17:27:40 CET 2004


Hello again,

I think this will help me:
http://www.math.montana.edu/Rweb/Rhelp/points.html

I'll email again if it doesn't.

Dave

-----Original Message-----
From: David Thibault 
Sent: Thursday, February 26, 2004 11:13 AM
To: R-help at r-project.org
Subject: Help with multicolored points in one plot

Hello all,

I have a situation where I'd like to plot points from multiple groups of
data in one plot.  I'd like each group's points to be colored a different
color.  I've seen people comment on how you can alternate colors by
providing a range of colors and then it will loop through each color as it
plots individual points.  However, that just goes by individual points and
not by group.  

Next I thought if, for example, I had 2 groups, I could make a 2 color
vector.  Then I could merge the data from my two groups alternating into an
X and Y vector, but that doesn't work either because the 2 groups may not
have equal numbers of members.  For example
-------------------------------
Group1_Xdata <- c(1,2,3,4,5)
Group2_Xdata <- c(10,20,30,40,50)

Colors <- c("red","blue")
Merged_XData <- c(1,10,2,10,3,30,4,40,5,50)

(SAME MERGE FOR Y DATA)
-----------------------------
That would work to make group1 red and group2 blue, but if Group 2 had 6
members instead of 5, then the 6th member would come out red.

Any thoughts?  Also, I want to be able to code this generically enough that
I can have any number of groups and colors.

Best Regards,
Dave




More information about the R-help mailing list