title: Overlapped density plots in ggplot2
body: <p>Imagine I have two vectors each of different length. I want to generate one plot with the density of both vectors overlaid. What I thought I should do is this:</p>
  
  <pre><code>vec1 &lt;- data.frame(x=rnorm(2000, 0, 1))
  vec2 &lt;- data.frame(x=rnorm(3000, 1, 1.5))
  ggplot() + geom_density(aes(x=x, colour="red"), data=vec1) + 
    geom_density(aes(x=x, colour="blue"), data=vec2)
  </code></pre>
  
  <p>Then I thought I should do this:</p>
  
  <pre><code>vec1 &lt;- data.frame(x=rnorm(2000, 0, 1))
  vec2 &lt;- data.frame(y=rnorm(3000, 1, 1.5))
  ggplot() + geom_density(aes(x=x, colour="red"), data=vec1) + 
    geom_density(aes(x=y, colour="blue"), data=vec2)
  </code></pre>
  
  <p>Neither of these quite work, because the colors get mixed up.</p>
  
  <p>Based on another solution I found in StackOverflow <a href="https://stackoverflow.com/questions/9768556/plot-vectors-of-different-length-with-ggplot2">1</a> <a href="https://stackoverflow.com/questions/6939136/how-to-overlay-density-plots-in-r">2</a>, I realized I should try this:</p>
  
  <pre><code>vec1 &lt;- data.frame(x=rnorm(2000, 0, 1), grp="vec1")
  vec2 &lt;- data.frame(x=rnorm(3000, 1, 1.5), grp="vec2")
  allDat &lt;- rbind(vec1, vec2)
  
  ggplot(allDat, aes(x, colour=grp)) + geom_density()
  
  ggplot(allDat, aes(x, colour=grp)) + geom_density() + 
    scale_colour_manual(values=c("green", "blue"))
  
  ggplot(allDat, aes(x, colour=grp)) + geom_density() + 
    scale_colour_manual(values=c(vec2="green", vec1="blue"))
  </code></pre>
  
  <p>OK, I solved my original problem. But is there a way to do something akin to the first one I tried above? From the way things are worded in the <code>ggplot</code> documentation, I would have thought so. Appreciate any suggestions.</p>