title: Combine legend in ggplot2
body: <p>I have a plot of multiple <code>geom_point</code> and a single <code>stat_function</code> in <code>ggplot2</code>. Is there a way to show a single legend?</p>
  
  <pre><code>df &lt;- data.frame("x"=c(1:5), "a"=c(1,2,3,3,3), "b"=c(1,1.1,1.3,1.5,1.5))
  df &lt;- melt(df, "x")
  p &lt;- ggplot(df, aes(x=x, y=value)) +
    geom_point(aes(colour=variable, shape=variable)) +
    stat_function(aes(colour="log2(x)"), fun=log2)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/cdkhO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cdkhO.png" alt="enter image description here"></a></p>
  
  <p>I want to have a single legend with the blue line and the two colored shapes. I tried</p>
  
  <pre><code>scale_colour_discrete(name="legend", breaks=c("a", "b", "log2(x)")) +
  scale_shape_discrete(name="legend", breaks=c("a", "b"))
  </code></pre>
  
  <p>but this does not work. Is there a way to do this automatically or by hand?</p>
  
  <p>Thanks in advance.</p>