ggplot2 - Adding a glm regression to a ggplot, where datapoints are colored after groups -
i trying visualize regression adding data plot, want color data points after group (eight different groups) , ggplot makes glm line each group instead of 1 including 8 groups. there way show 8 groups (color data points) , put regression line on top?
i‘ve included image of looks when use syntax:
ggplot(data=sig, aes(x=logdistance, y=amplitude,colour=dyrn)) + geom_point() + ylab("intensitet af kald") + xlab("logdistance")+geom_smooth(method=glm,data = sig)
in plot include data points colored groups, regression has been computed in lme4 package, include second line theoretical relationship, have shaded area surrounding glm line.
anybody can help?
you need apply colour aesthetic geom_point:
ggplot(data=sig, aes(x=logdistance, y=amplitude)) + geom_point(aes(colour=dyrn)) + geom_smooth(method=glm,data = sig) + ylab("intensitet af kald") + xlab("logdistance") 
Comments
Post a Comment