title: Color regression lines in geom_smooth depending on the slope of the underlying linear models
body: <p>In this illustrative data:</p>
  <pre><code>set.seed(12)
  df &lt;- data.frame(
    Sequ = c(rep(1,7),rep(2,10),rep(3,14),rep(4,10)),
    Q = c(rep(&quot;q_pol&quot;,7), rep(&quot;q_wh&quot;,10),rep(&quot;q_pol&quot;,14),rep(&quot;q_wh&quot;,10)),
    pp = c(rnorm(7), rnorm(10,1), rnorm(14,2), rnorm(10,3))
  )
  </code></pre>
  <p>there are <code>pp</code>  observations grouped by <code>Sequ</code> and <code>Q</code>. I want to plot linare regression lines for such groupings of <code>pp</code>. This I can do. However, I also need to distinguish the regression lines by whether their slope is negative or positive. I can get at the slopes this way: how can the regression lines be colored accordingly?</p>
  <pre><code>library(dplyr)
  libraryggplot2)
  df %&gt;%
    group_by(Sequ) %&gt;%
    mutate(x = row_number()) %&gt;%
    mutate(slope = lm(pp ~ x)$coeff[2]) %&gt;%
    ggplot(
      aes(x = x, y = pp, color = as.character(Sequ))) +
    geom_smooth(method = &quot;lm&quot;, se = FALSE) +
    facet_wrap(. ~ Q, scales = 'free_x') + 
    theme(legend.position = &quot;none&quot;)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/VJxOJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VJxOJ.png" alt="enter image description here" /></a></p>