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).
Here's some sample data, and a plot.
# Example data: normal CDFs
library(ggplot2)
category <- 1:100
X <- seq(0, 1, by = .1)
df <- data.frame(expand.grid(category, X))
names(df) <- c("category", "X")
df <- within(df, {
Y <- pnorm(X, mean = category / 100)
category <- factor(category)
})
# Plot with ggplot
qplot(data = df, x = X, y = Y, color = category, geom = "line")
This produces a pretty rainbow thing (below)
but I'd rather have a gradient from blue to red. Any ideas how I can do that?