Legend for two aesthetics and geom_abline in ggplot2
<p>I'm trying to prepare a legend for the following plot, with dotted followed by A and dashed followed by B. It is not showing correctly. As I have 2 aesthetic, it sometimes show only one line type or sometimes, nothing. I've used <code>scale_linetype_manual()</code> and <code>guides()</code>, however it was not able to produce the desired effect. But </p>

<p>The code that I've created, I've remove the code that showing my attempts of making a legend.</p>

<pre><code>exemplo&lt;-data.frame(Location = c("Tiburon Peninsula", "San Francisco","Santa Barbara area", "Santa Monica Mountains", "Marin County", 
                             "Santa Cruz Mountains", "Monterey County", "San Diego County","California Coast"),
                Area = c(5.9, 45, 110, 320, 529, 1386, 3324,4260, 24520),
                Species = c(370L, 640L, 680L, 640L, 1060L, 1200L,1400L, 1450L, 2525L))
modelo&lt;-lm(log(Species,10)~log(Area,10),data=exemplo)

modelo_nls&lt;-nls(Species~a*Area^z,start=list(a=1,z=0.25),data=exemplo)
linha&lt;-data.frame(x=log10(seq(1,25000,100)),y=log10(predict(modelo_nls,newdata=data.frame(Area=seq(1,25000,100)))))
ggplot(data=exemplo,aes(x=log10(Area),y=log10(Species)) )  + geom_point() +
geom_abline(intercept = modelo$coefficients[1], slope = modelo$coefficients[2],linetype="dotted") +
geom_line(data=linha,aes(x=x,y=y),linetype="dashed")+        
xlab(label="Área(ha)") + ylab(label="Número de espécies")
</code></pre>