I have the following chunk of script for creating a scatter plot with an lm line and an lm line through the origin:
xyplot(nbsp~FRic, groups = Ecoregion,data=dataplot, xlab="Functional Richness", ylab="Species Richness",
panel=function(x, y, groups) {
panel.xyplot(x, y)
panel.abline(lm(y~x), col='blue')
panel.abline(lm(y~x+0), col='red')
},
type='l',
auto.key = list(title='Ecoregion', space='right')
)
Which gets me a correct plot, but all the points are the same colour and don't match up to the groups represented in the legend. (Sorry I don't have enough reputation points to post pictures) However, I need the colours of the points to match up to the legend, and whatever I do I cannot get them to.
Any and all help would be greatly appreciated. I've rewritten this chunk more times than I can count, and I'm sure it's a silly error.
Thanks, Katherine