I got the following problem in R studio. Im trying to make a plot of different time series using different colours, which so far worked finde with the ggplot tool. However I did not manage to accually write a name to the correct layers. Below you can see the code that I wrote and also woks. Remember, the code works, meaning I get a plot with all 9 timeseires from aa until ii. I just could not figure out how to label the different layers. What should I do when I would like to add a name to the red line, the green line and so on beside the plot (in al list). Thank you for your time.
Best Matthias aa <- OHC_d[40:70] bb <- OHC_d[50:80] cc <- OHC_d[173:203] dd <- OHC_d[205:235] ee <- OHC_d[273:303] ff <- OHC_d[292:322] gg <- OHC_d[302:332] hh <- OHC_d[370:400] ii <- OHC_d[381:411] s3 <- data.frame(aa,bb,cc,dd,ee,ff,gg,hh,ii) y2 <- ggplot(s3,aes(x=time2,y=aa),colour="black") + geom_line() + geom_line(data=s3,aes(y=bb),colour="red") + geom_line() + geom_line(data=s3,aes(y=cc),colour="green") + geom_line() + geom_line(data=s3,aes(y=dd),colour="blue") + geom_line() + geom_line(data=s3,aes(y=ee),colour="yellow") + geom_line() + geom_line(data=s3,aes(y=ff),colour="pink") + geom_line() + geom_line(data=s3,aes(y=gg),colour="purple")+ geom_line()+ geom_line(data=s3,aes(y=hh),colour="violet") geom_line()+ geom_line(data=s3,aes(y=ii),colour="grey") y2 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.