Adding legend to a multi-histogram ggplot
<p>I'm trying to add a legend to a <code>ggplot</code> of two histograms, that may overlap and therefore would like to have them slightly transparent:</p>

<pre><code>library(ggplot2)
set.seed(1)
plot.df &lt;- data.frame(x=c(rnorm(1000,30,1),rnorm(10000,40,5)),
                      group=c(rep("a",1000),rep("b",10000)))
</code></pre>

<p>using:</p>

<pre><code>ggplot(plot.df,aes(x=x,fill=factor(group)))+ 
  geom_histogram(data=subset(plot.df,group=='a'),fill="red",alpha=0.5)+
  geom_histogram(data=subset(plot.df,group=='b'),fill="darkgray",alpha=0.5)+
  scale_colour_manual(name="group",values=c("red","darkgray"),labels=c("a","b"))+scale_fill_manual(name="group",values=c("red","darkgray"),labels=c("a","b"))
</code></pre>

<p>but all I get is:</p>

<p><a href="https://i.stack.imgur.com/ESgjs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ESgjs.png" alt="enter image description here"></a></p>

<p>What's missing?</p>