Skip to content
Prev 156717 / 398506 Next

adding layers in ggplot2 (data and code included)

The way you've attempted to get this result seems to align with the way 
R "should" work, but it fails in this case.
The fix is to break things up a little bit:

p <- ggplot(mydata, aes(x=Est, y=Tri))
p <- p + geom_point(aes(colour=factor(Group),shape=factor(Group)))
p <- p + 
geom_smooth(aes(group=factor(Group),color=factor(Group)),method=lm,se=F)
p


Eric
Juliet Hannah wrote: