[R] plotting multiple graphs in a single plot

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Thu Apr 27 09:52:12 CEST 2006


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




More information about the R-help mailing list