Re: [R] xyplot, groups and colors

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


Philipp,

I would do the following with ggplot2:

# Set up data

require(ggplot2)
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

Jeremy Hetzel
Boston University

        [[alternative HTML version deleted]]



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. 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive