title: ggplot2 + ggrepel adding legend with label colours changes the colours itself
body: <p>Assume the following data:</p>
  <pre><code>library(tidyverse)
  library(ggrepel)
  df &lt;- data.frame(name   = rep(letters[1:3], 3),
                   points = c(5, 3, 7, 12, 13, 14, 20, 30, 40),
                   time = rep(c(&quot;day 1&quot;, &quot;day 2&quot;, &quot;day 3&quot;), each = 3))
  
  df2 &lt;- df %&gt;%
    group_by(name) %&gt;%
    mutate(points_sum = cumsum(points)) %&gt;%
    group_by(time) %&gt;%
    mutate(rank = rank(desc(points_sum), ties.method = &quot;min&quot;)) %&gt;%
    ungroup() %&gt;%
    mutate(name_colour = case_when(rank == 1 ~ &quot;#336600&quot;,
                                   rank == 2 ~ &quot;#339900&quot;,
                                   rank == 3 ~ &quot;#66ff33&quot;))
  </code></pre>
  <p>I now want to draw th following plot, i.e. give the names/labels the colour specified in the <code>name_colour</code> column:</p>
  <pre><code>df2 %&gt;%
    ggplot(aes(x     = time,
               y     = points_sum,
               group = name,
               label = name)) +
    geom_point() +
    geom_text_repel(direction = &quot;y&quot;, size = 10, colour = df2$name_colour) +
    theme_minimal()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/TIasN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TIasN.png" alt="Plot without legend" /></a></p>
  <p>However, this plot is missing a legend for these colours, i.e. I want to add a legend that has the ranks next to the according colour.</p>
  <p>I'm not sure how I could manually add such a legend here. I tried to change my code above by the one below (only chenge in the second to last line), but this completely changes the colours of the labels:</p>
  <pre><code>df2 %&gt;%
    ggplot(aes(x     = time,
               y     = points_sum,
               group = name,
               label = name)) +
    geom_point() +
    geom_text_repel(direction = &quot;y&quot;, size = 10, aes(colour = name_colour)) +
    theme_minimal() 
  </code></pre>
  <p><a href="https://i.stack.imgur.com/2Lku4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Lku4.png" alt="Plot with legend, but wrong colours" /></a></p>
  <p>Any ideas?</p>