I have to use a rather complicated color-coding scheme to be able to differentiate several lines/points. For instance, I use open symbols where I can differentiate between fill and color. The following graph is plotted:
https://portal.idiv.de/nextcloud/index.php/s/LEJ9gnpN3fB6kAK
However, on top of this, I would like to plot one single line of what is the mean of all the lines. But as I already specified the aesthetics above with fill and color I cannot undo this, but this would be needed....
Further, is there a chance to have one legend combining shapes, lines and colors? The problem is, that for one line I cannot plot a regression line as there is just one x-value...
The code:
#dataset
data.red <- read_csv("https://www.idiv.de/fileadmin/content/Files_EIE/Teaching/data.red.csv")
#color coding etc
experiment <- factor(data.red1$experiment, levels= c("SATAKUNTA","BANGOR", "BIOTREE", "FORBIO","IDENT_AUCLAIR", "IDENT_MN", "KREINITZ", "ORPHEE", "BEFChina","SABAH", "SARDINILLA"))
color.experiment <-c("#2b83ba","#78c588", "#3f6d49","#018571","#123f1b","#78c588","#3f6d49","#018571","#fdae61","#d7191c","#d7191c")
fill.experiment <- c("#2b83ba", "#ffffff","#ffffff","#ffffff","#ffffff","#78c588","#3f6d49","#018571","#fdae61","#000000","#000000")
line.experiment <- c("solid", "solid", "dashed", "dotted", "dotdash", "longdash", "twodash", "dashed", "solid", "solid", "dashed")
#plot
ggplot(data.red, aes(x=log.div.level , y=bas, color=experiment, shape=experiment, fill=experiment)) +
labs(x="SR", y="value") +
geom_point(stroke = 1.3)+
geom_smooth(method=lm, se=F, na.rm=F, aes(linetype=experiment))+
scale_shape_manual(name = "Experiment", breaks=c("SATAKUNTA","BANGOR", "BIOTREE", "FORBIO","IDENT_AUCLAIR", "IDENT_MN", "KREINITZ", "ORPHEE", "BEFChina","SABAH", "SARDINILLA"), values=c(15,24,24,24,24,25,25,25,16,18,5))+
scale_colour_manual(name = "Experiment", breaks=c("SATAKUNTA","BANGOR", "BIOTREE", "FORBIO","IDENT_AUCLAIR", "IDENT_MN", "KREINITZ", "ORPHEE", "BEFChina","SABAH", "SARDINILLA"), values=color.experiment)+
scale_fill_manual(name = "Experiment", breaks=c("SATAKUNTA","BANGOR", "BIOTREE", "FORBIO","IDENT_AUCLAIR", "IDENT_MN", "KREINITZ", "ORPHEE", "BEFChina","SABAH", "SARDINILLA"), values=fill.experiment)+
scale_linetype_manual(name = "Experiment", breaks=c("SATAKUNTA","BANGOR", "BIOTREE", "FORBIO","IDENT_AUCLAIR", "IDENT_MN", "KREINITZ", "ORPHEE", "BEFChina","SABAH", "SARDINILLA"), values=line.experiment)