I combined two dataset in one plot, the observed distribution is built from "raw data" like "12,13,15,15,14,14,13,..."; while the expected distribution is built from probability like: "13 0.35;14 0.41; 15 0.23,..."
with the code below:
ggplot(Obs_hetero,aes(x=K_i))+
ggtitle("...") +
xlab("No. of Heterozygous Loci (K)") + ylab("Frequency/Density")+
geom_density(aes(x=K_i,y=..density..),colour="black",fill="red",alpha=.2)+
geom_point(mapping=aes(x=K,y=Density),color="blue",data = Expdist_K_unlinked) +
geom_line(mapping=aes(x=x,y=y),colour="blue",data=spl,stat = "identity",size=1)+
geom_area(mapping = aes(x=x,y=y),fill="blue",data=spl,alpha=.2)
After this, I would like to add a legend to this plot... But I cannot find how.