Judith Flores
2008-Feb-26 21:34 UTC
[R] Multiple lines with a different color assigned to each line
Dear R-experts,
I want to assign different colors to groups of
points, lines and segments in a plot.
I have a vector(dat$tx) that is going to have a
different number of levels every time the user wants
to plot a set of data. The number of lines is going to
be equal to the number of levels of the vector
mentioned.
What I have so far is this:
plot(1,1,type="n")
for (i in dat$tx) {
points(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
lines(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
}
How can I assign different colors to the points and
lines?
Thank you in advance for any help,
Judith
____________________________________________________________________________________
Be a better friend, newshound, and
John Kane
2008-Feb-26 21:49 UTC
[R] Multiple lines with a different color assigned to each line
I am not sure if I completely understand but would something like this work? (not tested) points(.... col=i) lines (.... col=i=1) --- Judith Flores <juryef at yahoo.com> wrote:> Dear R-experts, > > I want to assign different colors to groups of > points, lines and segments in a plot. > > I have a vector(dat$tx) that is going to have a > different number of levels every time the user wants > to plot a set of data. The number of lines is going > to > be equal to the number of levels of the vector > mentioned. > > What I have so far is this: > > plot(1,1,type="n") > for (i in dat$tx) { > > > points(summ$timep[summ$tx==i],summ$mn[summ$tx==i]) > lines(summ$timep[summ$tx==i],summ$mn[summ$tx==i]) > } > > How can I assign different colors to the points and > lines? > > Thank you in advance for any help, > > Judith > > > >____________________________________________________________________________________> Be a better friend, newshound, and > > ______________________________________________ > R-help at r-project.org 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. >[[elided Yahoo spam]]