How to recycle colors in the colorbrewer palette using line characters

I use ggplot2 to create quite a few facet_wrapped drawings geom_line.

Despite the fact that each chart has a maximum of eight lines, if taken together, for a legend there are more than twenty categories.

In the same vein: Recommend color scales for 13 or more categories and this: In R, how to change the color value of only one value in ggplot2's scale_fill_brewer? I would like to artificially increase the number of colors that I can show using colorbrewer high- contrasting colors.

The obvious way to do this would seem to be to “recycle” the colors in the palette with a different line symbol each time. Thus, the bright red color with “x on the line” may differ from the bright red color with “o”, etc.

Can anyone think how I can do this?

Thank!

Edit

Here are some (sanitized) data to play back, and the R code that I use to create my plot.

Data: http://orca.casa.ucl.ac.uk/~rob/Stack%20Overflow%20question/stack%20overflow%20colours%20question%20data.csv

R code:

csvData <- read.csv("Qaru 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")
+5
source share
1 answer

Created data frame containing 20 levels (in the form of letters).

df<-data.frame(group=rep(c(LETTERS[1:20]),each=5),x=rep(1:5,times=20),y=1:100)

scale_colour_manual() - , SET1 times ( 20). , , geom_point() scale_shape_manual(), each ( 20).

library(RColorBrewer)
ggplot(df,aes(x,y,colour=group))+geom_line()+geom_point(aes(shape=group),size=5)+
  scale_colour_manual(values=rep(brewer.pal(5,"Set1"),times=4))+
  scale_shape_manual(values=rep(c(15,16,17,18,19),each=5))

enter image description here

+13