title: ggplot2: coloring segments of single line with different colors
body: <p>I would like to plot two lines and then color segments of a single line with different colors.
  Here is a simple code:</p>
  
  <pre><code>temp &lt;- data.frame(x = c(2, 4, 5, 5, 7, 6, 7, 8, 10, 9),
              y = c(3, 8, 4, 8, 8, 4, 9, 12, 5, 1),
              line = c('a', 'a', 'a', 'a', 'a', 'b', 'b', 'b', 'b', 'b'),
              color = c('c', 'c', 'd', 'd', 'd', 'c', 'c', 'c', 'd', 'd'))
  
  ggplot() +
    geom_line(aes(x, y, linetype = line, color = ???), data = temp)
  </code></pre>
  
  <p>I want to color segments of each line using the <code>color</code> factor. Any help? Thank you in advance!</p>