kavaumail-r at yahoo.com
2006-Apr-27 04:06 UTC
[R] plotting multiple graphs in a single plot
Hi, I would like to plot multiple graphs in a single plot frame. Something like this: plot(X, Y1, type='l', col='red') lines(X, Y2, col='green') lines(X, Y3, col='blue') etc. The problem with this approach is, however, that the range of the y-axis will be set according to the minimum and maximum values of Y1 only. I would like to generate a plot that shows all the values of Y1, Y2, and Y3, no matter what their ranges are. Is there an easy way to do this? Thanks Klaus
you should use: plot(X, Y1, type='l', col='red', ylim = range(Y1, Y2, Y3)) lines(X, Y2, col='green') lines(X, Y3, col='blue') I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: <kavaumail-r at yahoo.com> To: <r-help at stat.math.ethz.ch> Sent: Thursday, April 27, 2006 6:06 AM Subject: [R] plotting multiple graphs in a single plot> Hi, > > I would like to plot multiple graphs in a single plot > frame. Something like this: > > plot(X, Y1, type='l', col='red') > lines(X, Y2, col='green') > lines(X, Y3, col='blue') > > etc. The problem with this approach is, however, that > the range of the y-axis will be set according to the > minimum and maximum values of Y1 only. I would like to > generate a plot that shows all the values of Y1, Y2, > and Y3, no matter what their ranges are. > > Is there an easy way to do this? > > Thanks > Klaus > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm