Re: [R] xyplot, groups and colors

From: Jeremy Hetzel <>
Date: Fri, 08 Apr 2011 08:31:00 -0400


I would do the following with ggplot2:

# Set up data

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

# Specify the ggplot group aesthetic as Tree
g1 <- ggplot(data = dat, aes(x = age, y = circumference, group=Tree))

# Specify the geom_point and geom_line colour aesthetics as group
g1 + geom_point(aes(colour = group)) + geom_line(aes(colour = group))

Is this what you are after?


Jeremy Hetzel
Boston University

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 08 Apr 2011 - 12:35:03 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 - 13:20:28 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive