I'm using ggplot2 to create quite a few facet_wrap
ped geom_line
plot.
Although each plot only has a maximum of eight lines, when taken together, there are more like twenty categories to show on the legend.
In a similar vein to this: Recommend a scale colour for 13 or more categories and this: In R,how do I change the color value of just one value in ggplot2's scale_fill_brewer? I'd like to artificially up the number of colours I can show using colorbrewer's high-contrast colour sets.
An obvious way to do this would seem to be to 'recycle' the colours in the palette, with a different line symbol each time. So bright red with 'x's on the line could be a different category than bright red with 'o's etc.
Can anyone think how I might do this?
Thanks!
Edit
Here's some (sanitised) data to play with, and the R code I'm using to produce my plot.
R code:
csvData <- read.csv("stack overflow colours question data.csv")
p <- ggplot(csvData,
aes(year, percentage_of_output, colour=category, group=category))
p +
geom_line(size=1.2) +
labs(title = "Can I recycle the palette colours?", y = "% of output") +
scale_colour_brewer(palette = "Set1") +
theme(plot.title = element_text(size = rel(1.5))) +
facet_wrap("country_iso3", scales="free_y")