Hi all! I new to R (I don't know anything about S+ either!) I've a simple question: How do I generate overlay plots in R? So far as I can see the plot(x, y) operator will only give me one graph and the plot(x ~ y + z) will give me 2 separate plots. Is there an easy way to overlay or am I missing the obvious? Any help welcome. Gerard Keogh The information in this email, and any attachments transmitted with it, are confidential and are for the intended recipient only. If you receive this message in error, please notify us via postmaster at cso.ie. To see the latest figures from the CSO go to http://www.cso.ie -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 6 Sep 2001 Gerard.Keogh at cso.ie wrote:> Hi all! > > I new to R (I don't know anything about S+ either!) > > I've a simple question: > > How do I generate overlay plots in R? > So far as I can see the plot(x, y) operator will only give me one graph and > the plot(x ~ y + z) will give me 2 separate plots. > Is there an easy way to overlay or am I missing the obvious?between two calls to plot you should set par(new=T) specify the xlim=c(x1,x2) ylim=c(y1,y2) in each call to plot() to get propper matching of the overlaid plots> > > Any help welcome. > > Gerard Keogh > > The information in this email, and any attachments transmitted with it, are confidential > and are for the intended recipient only. If you receive this message in error, please > notify us via postmaster at cso.ie. > > To see the latest figures from the CSO go to http://www.cso.ie > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >*********************************************************************** Jens Nieschulze Institute for Forest Biometrics & Phone: ++49-551-39-12107 Applied Computer Science Fax : ++49-551-39-3465 Buesgenweg 4 37077 Goettingen E-mail: jniesch at uni-forst.gwdg.de GERMANY http://www.uni-forst.gwdg.de/~jniesch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 06 Sep 2001 15:08:16 +0100, you wrote in message <OF62D87A41.4733FB80-ON80256ABF.004D2E97 at cso.ie>:>Hi all! > >I new to R (I don't know anything about S+ either!) > >I've a simple question: > >How do I generate overlay plots in R? >So far as I can see the plot(x, y) operator will only give me one graph and >the plot(x ~ y + z) will give me 2 separate plots. >Is there an easy way to overlay or am I missing the obvious? > > >Any help welcome.The general scheme in R (and S+) is that one call sets up a plotting region and establishes a coordinate system, and possibly fills it, and then further calls can be used to embellish it. What you want to do is to use one call to plot y vs. x, then add the z vs. x points to that plot. A simple way to do that is plot(x, y) points(x, z) Note that the horizontal coordinate is listed first when you list arguments, but the vertical coordinate is listed first when you use a formula, so this is equivalent: plot(y ~ x) points(z ~ x) Because the first call establishes the coordinates, you might find that not all the z values are shown. To guarantee this, you can use optional arguments in the first call, e.g. plot(x, y, ylim = range(c(y,z))) You should also look at "axis", "lines", "text", "mtext", "box" etc. for other functions to embellish the plot. Duncan Murdoch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._