Skip to content

xyplot, groups and colors

4 messages · David Winsemius, Dennis Murphy, Philipp Pagel

#
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.

Example:

# 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?

cu
	Philipp
#
On Apr 8, 2011, at 8:06 AM, Philipp Pagel wrote:

            
You aren't saying what you want but I am guessing it is a color-less  
plot:

xyplot(circumference~age, dat, groups=Tree, type='l',
         par.settings=simpleTheme(col="grey"))

trellis.par.set can also  be used to specify this globally.
2 days later
#
On Fri, Apr 08, 2011 at 08:14:21AM -0700, Dennis Murphy wrote:
Thanks to everyone who replied! Especialy this and the ggplot advice
did what I wanted.
This is essentially what I had been doing after somehow creating the
correct color vector.
Perfect! Using the levels directly had not occured to me. Thanks!

cu
	Philipp