r - xyplot panel function overriding group colours -


i have following chunk of script creating scatter plot lm line , lm line through 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 correct plot, points same colour , don't match groups represented in legend. (sorry don't have enough reputation points post pictures) however, need colours of points match legend, , whatever cannot them to.

any , appreciated. i've rewritten chunk more times can count, , i'm sure it's silly error.

thanks, katherine

i think want. careful function arguments.

xyplot(nbsp~fric, groups = ecoregion,        data=dataplot, xlab="functional richness",         ylab="species richness",        panel=function(x, y, groups=groups,...) {          panel.xyplot(x, y, groups=groups,...)          panel.abline(lm(y~x), col='blue')          panel.abline(lm(y~x+0), col='red')        },        type='l',        auto.key = list(title='ecoregion', space='right') ) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -