title: How do you create a gradient of colors for a discrete variable in ggplot2?
body: <p>I have data with about 100 ordered categories.  I would like to plot each category as a line separately, with the line colors ranging from a low value (say, blue) to a high value (say, red).</p>
  
  <p>Here's some sample data, and a plot.</p>
  
  <pre><code># Example data: normal CDFs
  
  library(ggplot2)
  
  category &lt;- 1:100
  X &lt;- seq(0, 1, by = .1)
  df &lt;- data.frame(expand.grid(category, X))
  names(df) &lt;- c("category", "X")
  df &lt;- within(df, {
    Y &lt;- pnorm(X, mean = category / 100)
    category &lt;- factor(category)
    })
  
  # Plot with ggplot
  qplot(data = df, x = X, y = Y, color = category, geom = "line")
  </code></pre>
  
  <p>This produces a pretty rainbow thing (below)<img src="https://i.stack.imgur.com/bIiwS.png" alt="enter image description here"></p>
  
  <p>but I'd rather have a gradient from blue to red.  Any ideas how I can do that?</p>