title: Conditional color for geom_line
body: <p>I would like to get a single line passing through given points and having specified colors for values which are within specified intervals. But I can only get multiple lines of the specified colors rather than a single line which would change colors on its subintervals.</p>
  
  <p>The reproducible example is as follows:</p>
  
  <pre><code>require(ggplot2)
  require(plotly)
  
  vectX &lt;- c(-5,-4.5,-3.2,-2.1,-0.8,0.1,1.3,2.7,3.6,4.4,5)
  vectY &lt;- c(-2.3,1.4,2.7,0.3,-0.4,1.5,3.9,2.4,0.5,-1.2,1.4)
  
  requestedQuantilesZscores &lt;-  c(0.0,0.25,0.5,0.75,1.0)
  zScores &lt;- base::scale(vectY, center = TRUE, scale = TRUE)
  quantilesZscore &lt;- stats::quantile(zScores, requestedQuantilesZscores, na.rm = TRUE)
  
  theDataFrame &lt;- base::data.frame(theX = vectX, theY = vectY, theZ = zScores)
  
  valuesColor &lt;- c('green','red','blue','yellow','orange')
  theDataFrame$conditionalColor &lt;- ifelse(theDataFrame$theZ &gt; quantilesZscore[[4]], valuesColor[[1]] ,
        ifelse(theDataFrame$theZ &gt; quantilesZscore[[3]] &amp; theDataFrame$theZ &lt;= quantilesZscore[[4]], valuesColor[[2]],
          ifelse(theDataFrame$theZ &gt; quantilesZscore[[2]] &amp; theDataFrame$theZ &lt;= quantilesZscore[[3]], valuesColor[[3]],
            ifelse(theDataFrame$theZ &lt;= quantilesZscore[[2]], valuesColor[[4]], valuesColor[[5]]))))
  
  theGGplotLine &lt;- ggplot(theDataFrame) +
    geom_line(aes(x = theX, y = theY, color = conditionalColor)) +
    xlab('X') + ylab('Y') +
    scale_colour_manual(values = valuesColor) +
    theme(legend.position='none')
  
  theGGplotLine
  
  (plotly::ggplotly(theGGplotLine))
  </code></pre>