title: How to add gradient to a geom_line while using multiple colour scales and date_breaks in ggplot
body: <p>I want to create a ggplot that includes a gradient colour fill for a <code>geom_line</code>, but also includes other things like manual colour and shape overwrites, and (discrete?) date breaks.</p>
  <p>If I only plot a <code>geom_line</code> with a <code>scale_colour_gradient</code> everything works fine:</p>
  <pre><code>set.seed(1)
  
  # dataframe
  df &lt;- data.frame (UP = c(5, 5, 3, 2),
                    Date = c(sort(sample(seq(as.Date(&quot;2018-06-01&quot;), as.Date(&quot;2019-06-01&quot;), by = &quot;day&quot;), 4))))
  
  # dataframe for gradient 
  df2 &lt;- data.frame (UP = seq(from = df[2, 1], to = df[3, 1], length.out = 100),
                          Date = seq.Date(from = df[2, 2], to = df[3, 2], length.out = 100))
  
  ggplot() +
    geom_line (data = df[1:2, ], aes (Date, UP), lty = &quot;longdash&quot;, col = &quot;blue&quot;, size = 1) + 
    geom_line (data = df[3:4, ], aes (Date, UP), lty = 1, col = &quot;red&quot;, size = 1) + 
    geom_point (data = df[1:2, ], aes (Date, UP), col = &quot;blue&quot;, shape = 4, stroke = 2, size = 3) +
    geom_point (data = df[3:4, ], aes (Date, UP), col = &quot;red&quot;, size = 3) +
    geom_line (data = df2, aes (Date, UP, color = as.integer(UP)), size = 1) +
    scale_colour_gradient(name = &quot;UP&quot;, 
                          low = &quot;red&quot;, high = &quot;blue&quot;)
  </code></pre>
  <p>From here, I want to add a sequences of statistics that have certain colours and shapes, and also break the x-axis by years using the scales package.</p>
  <pre><code>set.seed(1)
  
  # dataframe for statistics
  df3 &lt;- data.frame (Stat = c(sample(2:4, 4, replace = TRUE)),
                     Date = df$Date,
                     Shape = c(&quot;DO&quot;, &quot;DO&quot;, &quot;RE&quot;, &quot;MI&quot;))
                 
  # plot including statistics tags
  p &lt;- ggplot() +
    geom_line (data = df[1:2, ], aes (Date, UP), lty = &quot;longdash&quot;, col = &quot;blue&quot;, size = 1) + 
    geom_line (data = df[3:4, ], aes (Date, UP), lty = 1, col = &quot;red&quot;, size = 1) + 
    geom_point (data = df[1:2, ], aes (Date, UP), col = &quot;blue&quot;, shape = 4, stroke = 2, size = 3) +
    geom_point (data = df[3:4, ], aes (Date, UP), col = &quot;red&quot;, size = 3) +
    geom_line (data = df3, aes (Date, Stat), lty = 2, size = 1) + 
    geom_point (data = df3[1:2, ], aes (Date, Stat, col = Shape, shape = Shape), size = 7) + 
    geom_point (data = df3[3, ], aes (Date, Stat, col = Shape, shape = Shape), size = 7) + 
    geom_point (data = df3[4, ], aes (Date, Stat, col = Shape, shape = Shape), size = 7) +
    scale_colour_manual(name=bquote(bold (&quot;TITLE&quot;)), 
                        values= c(&quot;red3&quot;, &quot;black&quot;, &quot;springgreen4&quot;),  
                        labels = c(&quot;DO&quot;,&quot;RE&quot;, &quot;MI&quot;)) +
    scale_shape_manual(name=bquote(bold (&quot;TITLE&quot;)),
                       values= c(15:17),
                       labels = c(&quot;DO&quot;,&quot;RE&quot;, &quot;MI&quot;)) +
    scale_x_date(date_breaks = &quot;year&quot;, 
                 labels = scales::date_format (&quot;%Y&quot;),
                 limits = as.Date(c(df[1,2], df[4,2]))) 
  </code></pre>
  <p>The problems start when I try to add the gradient <code>geom_line</code> to this latter plot, resulting in the following errors:</p>
  <p><em>Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale.
  Error: Discrete value supplied to continuous scale</em></p>
  <pre><code>p + geom_line (data = df2, aes (Date, UP, color = as.integer(UP)), size = 1) +
    scale_colour_gradient(name = &quot;UP&quot;, 
    low = &quot;red&quot;, high = &quot;blue&quot;)
  </code></pre>
  <p>Do you know how to tackle this problem? Any help is very much appreciated.</p>