Questions 2 and 3 you answered yourself - the color brewer palettes are suitable. The hard question is 1, but like Nick I'm afraid it is based on a false hope. The color of the lines are not what makes one be able to distinguish between the lines easily, it is based on continuity and how tortuous the lines are. Thus there are design based choices, other than the color or dash pattern of the lines, that will aid in making the plot easier to interpret.
I will steal one of Frank's diagrams showing the flexibility of splines to approximate many different shaped functions over a limited domain as an example.
#code adapted from http://biostat.mc.vanderbilt.edu/wiki/pub/Main/RmS/rms.pdf page 40
library(Hmisc)
x <- rcspline.eval(seq(0,1,.01), knots=seq(.05,.95,length=5), inclx=T)
xm <- x
xm[xm > .0106] <- NA
x <- seq(0,1,length=300)
nk <- 6
set.seed(15)
knots<-seq(.05,.95,length=nk)
xx<-rcspline.eval(x,knots=knots,inclx=T)
for(i in 1:(nk−1)){
xx[,i]<-(xx[,i]−min(xx[,i]))/
(max(xx[,i])−min(xx[,i]))
for(i in 1:20){
beta<-2∗runif(nk−1)−1
xbeta<-xx%∗%beta+2∗runif(1)−1
xbeta<-(xbeta−min(xbeta))/
(max(xbeta)−min(xbeta))
if (i==1){
id <- i
MyData <- data.frame(cbind(x,xbeta,id))
}
else {
id <- i
MyData <- rbind(MyData,cbind(x,xbeta,id))
}
}
}
MyData$id <- as.factor(MyData$id)
Now this produces quite a tangled mess of 20 lines, a difficult challenge to visualize.
library(ggplot2)
p1 <- ggplot(data = MyData, aes(x = x, y = V2, group = id)) + geom_line()
p1
Here is the same plot in small multiples, at the same size, using wrapped panels. It is slightly more difficult to make comparisons across panels, but even in the shrunken space it is much easier to visualize the shape of the lines.
p2 <- p1 + facet_wrap(~id) + scale_x_continuous(breaks=c(0.2,0.5,0.8))
p2
One point that Stephen Kosslyn makes in his books is that it isn't how many different lines make the plot complicated, it is how many different types of shapes the lines can take. If 20 panels end up being too small, you can frequently reduce the set to similar trajectories to place in the same panel. It is still hard to distinguish between the lines within the panels, by definition they will be nearby each over and overlap frequently, but it reduces the complexity of making between panel comparisons quite a bit. Here I arbitrarily reduced the 20 lines into 4 separate groupings. This has the added benefit that direct labelling of lines is simpler, there is more space within the panels.
###############1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
newLevels <- c(1,1,2,2,2,2,2,1,1, 2, 3, 3, 3, 3, 2, 4, 1, 1, 2, 1)
MyData$idGroup <- factor(newLevels[MyData$id])
p3 <- ggplot(data = MyData, aes(x = x, y = V2, group = id)) + geom_line() +
facet_wrap(~idGroup)
p3
There is a general phrase that is applicable to the situation, if you focus on everything you focus on nothing. In the case with only ten lines, you have (10*9)/2=45
possible pairs of lines to compare. We probably are not interested in all 45 comparisons in most circumstances, we are either interested in comparing specific lines to each other or comparing one line to the distribution of the rest. Nick's answer shows the latter nicely. Drawing the background lines thin, light colored, and semi-transparent, and then drawing the foreground line in any bright color and thicker will be sufficient. (Also for the device make sure to draw the foreground line on top of the other lines!)
It is much more difficult to create a layering where each individual line can be easily distinguished in the tangle. One way to accomplish foreground-background differentiation in cartography is the use of shadows, (see this paper by Dan Carr for a good example). This will not scale up to 10 lines, but can help for 2 or 3 lines. Here is an example for the trajectories in Panel 1 using Excel!
There are other points to make, such as the light grey lines can be misleading if you have trajectories that are not smooth. E.g. you could have two trajectories in the shape of an X, or two in the shape of one right side up and upside down V. Drawing them the same color you wouldn't be able to trace the lines, and this is why some suggest drawing parallel coordinate plots using smooth lines or jittering/off-setting the points (Graham and Kennedy, 2003; Dang et al., 2010).
So the design advice can change depending on the end goal and the nature of the data. But when making bivariate comparisons between the trajectories is of interest, I think the clustering of similar trajectories and using small multiples makes the plots much easier to interpret in a wide variety of circumstances. This I feel is generally more productive than any combination of colors/line dashes will be in complicated plots. Singled panel plots in many articles are much larger than they need to be, and splitting into 4 panels is typically possible within page constraints without much loss.