[R] Custom manual legend in ggplot2

Giorgio Garziano giorgio.garziano at ericsson.com
Wed Dec 9 16:20:24 CET 2015


Last "+theme_bw()" to be deleted.

Try this:

ggplot(data1, aes(x=x1, y=y1))+
  geom_point()+
  geom_smooth(method="glm", family="gaussian",aes(linetype="equation1"))+
  geom_smooth(aes(x=x1, y=y1, linetype="equation2"),data=data2, method="glm", family="gaussian")+
  scale_linetype_manual(values = c("solid","dashed"),name="Equations",
                        labels = c("Equation 1","Equation 2"),guide="legend")+
  theme(plot.title = element_text(lineheight=.8, face="bold"), legend.position="top")


--

GG

http://around-r.blogspot.it




	[[alternative HTML version deleted]]



More information about the R-help mailing list