title: Reasons that ggplot2 legend does not appear
body: <p>I was attempting (unsuccessfully) to show a legend in my R ggplot2 graph which involves multiple plots. My data frame <code>df</code> and code is as follows:</p>
  
  <pre><code>  Individuals        Mod.2        Mod.1          Mod.3
  1           2 -0.013473145  0.010859793    -0.08914021
  2           3 -0.011109863  0.009503278    -0.09049672
  3           4 -0.006465788  0.011304668    -0.08869533
  4           5  0.010536718  0.009110458    -0.09088954
  5           6  0.015501212  0.005929766    -0.09407023
  6           7  0.014565584  0.005530390    -0.09446961
  7           8 -0.009712516  0.012234843    -0.08776516
  8           9 -0.011282278  0.006569570    -0.09343043
  9          10 -0.011330579  0.003505439    -0.09649456
  
  str(df)
      'data.frame':   9 obs. of  4 variables:
       $ Individuals   : num  2 3 4 5 6 7 8 9 10
       $ Mod.2         : num  -0.01347 -0.01111 -0.00647 0.01054 0.0155 ...
       $ Mod.1         : num  0.01086 0.0095 0.0113 0.00911 0.00593 ...
       $ Mod.3         : num  -0.0891 -0.0905 -0.0887 -0.0909 -0.0941 ...
  
  ggplot(df, aes(df$Individuals)) +
      geom_point(aes(y=df[,2]), colour="red") + geom_line(aes(y=df[,2]), colour="red") +
      geom_point(aes(y=df[,3]), colour="lightgreen") + geom_line(aes(y=df[,3]), colour="lightgreen") +
      geom_point(aes(y=df[,4]), colour="darkgreen") + geom_line(aes(y=df[,4]), colour="darkgreen") +
      labs(title = "Modules", x = "Number of individuals", y = "Mode")
  </code></pre>
  
  <p>I looked up the following stackflow threads, as well as Google searches:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/43213264/merging-ggplot2-legend">Merging ggplot2 legend</a></li>
  <li><a href="https://stackoverflow.com/questions/37931541/ggplot2-legend-not-showing">ggplot2 legend not showing</a></li>
  <li><a href="https://stackoverflow.com/questions/22532236/ggplot2-legend-not-showing-label-for-added-series">`ggplot2` legend not showing label for added series</a></li>
  <li><a href="https://stackoverflow.com/questions/47743916/ggplot2-legend-for-geom-area-geom-ribbon-not-showing">ggplot2 legend for geom_area/geom_ribbon not showing</a></li>
  <li><a href="https://stackoverflow.com/questions/3427457/ggplot-and-r-two-variables-over-time">ggplot and R: Two variables over time</a></li>
  <li><a href="https://stackoverflow.com/questions/48693431/ggplot-legend-not-showing-up-in-lift-chart">ggplot legend not showing up in lift chart</a></li>
  <li><a href="https://stackoverflow.com/questions/40967101/why-ggplot2-legend-not-show-in-the-graph">Why ggplot2 legend not show in the graph</a></li>
  <li><a href="https://stackoverflow.com/questions/48693431/ggplot-legend-not-showing-up-in-lift-chart">ggplot legend not showing up in lift chart</a>.
  This one was created 4 days ago</li>
  </ul>
  
  <p>This made me realize that making legends appear is a recurring issue, despite the fact that legends usually appear automatically.</p>
  
  <p>My first question is what are the causes of a legend to not appear when using ggplot? The second is how to solve these causes. One of the causes appears to be related to multiple plots and the use of <code>aes()</code>, but I suspect there are other reasons.</p>