title: Adding key legend to multi-histogram plot in R
body: <p>How do I add a key legend to the below plot</p>
  
  <p><img src="https://i.stack.imgur.com/WWinE.jpg" alt="enter image description here"></p>
  
  <p>I whish to have a key legend somewhere in the upper right corner with two short horizontal color bars, where the red one should say "Plastic surgery gone wrong" and the blue one should say "Germany".</p>
  
  <p>I used the following code to produce the plot:</p>
  
  <pre><code>bar2 &lt;- read.table("div/ana-mut[...]/barriers-set-2.dat", sep=" ")
  bar2val &lt;- c(bar2$V1, bar2$V2)
  bar3 &lt;- read.table("div/ana-mut[...]/barriers-set-3.dat", sep=" ")
  bar3val &lt;- c(bar3$V1, bar3$V2)
  p1 &lt;- hist(subset(bar2val, bar2val &lt; 30), breaks=30)
  p2 &lt;- hist(subset(bar3val, bar3val &lt; 30), breaks=30)
  plot(p1, col=rgb(1,0,0,8/9), main="Barrier distribution", xlab="Barrier [kcal/mol]", ylab="Mutant count")
  plot(p2, col=rgb(0,0,1,8/9), add=T)
  </code></pre>
  
  <p>Any hints would be greatly appreciated.</p>