[R] xyplot, groups and colors

From: Philipp Pagel <p.pagel_at_wzw.tum.de>
Date: Fri, 08 Apr 2011 14:06:56 +0200

        Dear ExpeRts,

I am trying to plot a bunch of growth curves and would like to get some more control over groups and line colors than I seem to have.


# make some data

dat <- Orange
dat$group <- ifelse(dat$Tree%in%c('1','4','5'), 'A', 'B')

# plot

xyplot(circumference~age, dat, groups=group)

# now use lines to make the growth curve more visible
xyplot(circumference~age, dat, groups=group, type='l')
# ugly, because of the 'return' lines

# to fix this set groups to Tree

xyplot(circumference~age, dat, groups=Tree, type='l')
# better, but now each Tree has its own color

Of course I can now use the col argument to manually assign the colors by group but is there a more elegant way that I missed?



Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 08 Apr 2011 - 12:09:37 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 Fri 08 Apr 2011 - 15:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive