I'm trying to plots insect counts of 2 species in 18 experimental plots onto a single graph. Since the second species population peaks later, it is visually doable (see picture below). I would like the 18 population lines from species 1 to be green (using "Greens" from RColorBrewer) and the 18 of species 2 to be red (using "Reds"). I do realize this may be problematic for a colourblind audience, but that is irrelevant here.
I've read here that it is not possible with standard ggplot2 options: R ggplot two color palette on the same plot but this post is more than two years old.
There is a short of "cheat" for points: Using two scale colour gradients ggplot2 but since I prefer lines to show the population through time, I can't use it.
Are there any new "cheats" available for this? Or does anyone have another idea to visualize my data in a way that shows population trends through time in all plots and shows the difference in timing of the peak? I've included a picture at the bottom that shows my real data, all in the same colour scale though.
Sample code
# example data frame plot <- as.factor(rep(c("A","B","C"),each=5)) time <- as.numeric(rep(c(1:5),times=3)) S1 <- c(1,4,7,5,2, 2,8,9,3,1, 1,6,6,3,1) S2 <- c(0,0,2,3,2, 1,2,1,5,3, 0,1,1,6,7) df <- data.frame(time, plot, S1, S2) # example colour scales S1Colours <- colorRampPalette(brewer.pal(9,"Greens"))(3) S2Colours <- colorRampPalette(brewer.pal(9,"Reds"))(3) names(S1Colours) <- levels(df$plot) names(S2Colours) <- levels(df$plot) # example plot ggplot(data=df) + geom_line(aes(x=time, y=S1, colour=plot)) + geom_line(aes(x=time, y=S2, colour=plot)) + scale_colour_manual(name = "plot", values = S1Colours) + scale_colour_manual(name = "plot", values = S2Colours) # this gives the note "Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale." Plot real data


