You can do this by adding a new column to each of your data frames to create fill and colour aesthetics to move on to the legend. In each case, there is only one category, but placing them inside aes() gives you the legends you want:
require(ggplot2) df <- data.frame(x=rnorm(10^4), fill=rep("Sample", 10^4)) p <- ggplot(df, aes(x=x)) + geom_histogram(aes(y=..density.., fill=fill), colour='black', alpha=0.8, width=0.2) + scale_fill_manual(values="steelblue") + labs(fill="") x <- seq(-4, 4, 0.01) df <- data.frame(x=x, y=dnorm(x), colour=rep("Theoretical Density",length(x))) p <- p + geom_line(data=df, aes(x=x, y=y, colour=line), size=1.5) + scale_colour_manual(values="red") + labs(colour="")

source share