title: ggplot2 - legend for combined geom_point and geom_line
body: <p>I am given a data set and would like to plot one variable as points and the others as lines with different line types (each variable in a distinct colour).</p>
  
  <pre><code> a &lt;- c(10:20)
   df &lt;- data.frame(a=a,b=a,c=a*a/10,d=10*sqrt(a))
   df_melt &lt;- reshape2::melt(df,id.vars='a')
  
   ggplot(df_melt, aes(x=a,y=value,colour=variable,linetype=variable,shape=variable))+
             geom_line(data=subset(df_melt,variable == "b"))+
             geom_line(data=subset(df_melt,variable == "c"))+
             geom_point(data=subset(df_melt,variable == "d"))
  </code></pre>
  
  <p>This yields now the wanted plot:</p>
  
  <p><a href="https://i.stack.imgur.com/zGdD3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zGdD3.png" alt="enter image description here"></a></p>
  
  <p>Yet, the legend now shows linetypes and shapes for all three variables, although not all variables actual display them.</p>
  
  <p>How can I remove line type or shape accordingly to make the legend consistent with the plot display?</p>