Arnaud Michel
2013-Aug-31 17:57 UTC
[R] To represent on the same plot the relation (y1, x) and (y2, x)
Hello, I have 3 vectors x, y1 and y2 I would like to represent on the same plot the two graph (y1, x) and (y2, x). Is it possible with ggplot ? other package ? Thanks for your help -- Michel ARNAUD Charg? de mission aupr?s du DRH DGDRD-Drh - TA 174/04 Av Agropolis 34398 Montpellier cedex 5 tel : 04.67.61.75.38 fax : 04.67.61.57.87 port: 06.47.43.55.31
arun
2013-Aug-31 19:27 UTC
[R] To represent on the same plot the relation (y1, x) and (y2, x)
Hi, May be this helps: ?x<- 1:10 ?set.seed(28) ?y1<- rnorm(10) set.seed(485) ?y2<- rnorm(10) ?plot(x,y1,col="red",type="b",ylab="y1:y2") lines(y2,col="blue",type="b") legend("topleft", legend = c("y1", "y2"),text.col=c("red","blue")) #or library(ggplot2) dat1<- data.frame(x,y1,y2) ggplot(dat1,aes(x))+geom_line(aes(y=y1,colour="y1"))+ ? geom_line(aes(y=y2,colour="y2")) +ylab("y1:y2") A.K. ----- Original Message ----- From: Arnaud Michel <michel.arnaud at cirad.fr> To: R help <r-help at r-project.org> Cc: Sent: Saturday, August 31, 2013 1:57 PM Subject: [R] To represent on the same plot the relation (y1, x) and (y2, x) Hello, I have 3 vectors x, y1 and y2 I would like to represent on the same plot the two graph (y1, x) and (y2, x). Is it possible with ggplot ? other package ? Thanks for your help -- Michel ARNAUD Charg? de mission aupr?s du DRH DGDRD-Drh - TA 174/04 Av Agropolis 34398 Montpellier cedex 5 tel : 04.67.61.75.38 fax : 04.67.61.57.87 port: 06.47.43.55.31 ______________________________________________ R-help at r-project.org mailing list 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.