I would like to plot two different scatterplots in the same frame (say with different colors) but everytime plot is called a new frame is created. Is there a way around this? -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Justin Fay wrote:> > I would like to plot two different scatterplots in the same frame (say with > different colors) but everytime plot is called a new frame is created. Is > there a way around this?try points() or par(new=TRUE) Best, Z> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
First scatterplot: plot(x,y,col="blue") second: points(z,t, col="red") Note that the coordinate system fixed by the first call to plot cannot be changed, so if tthe (z,t) points fall outside, it is necessary to include xlim=c(,) and ylim=c(,) as arguments to the first call. Kjetil Halvorsen. Justin Fay wrote:> > I would like to plot two different scatterplots in the same frame (say with > different colors) but everytime plot is called a new frame is created. Is > there a way around this? > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Justin Fay <jcfay at lbl.gov> writes:> I would like to plot two different scatterplots in the same frame (say with > different colors) but everytime plot is called a new frame is created. Is > there a way around this?[...] Justin To answer your question try the "points" function. Might I also recommend one of the introductory guides like ``Using R for Data Analysis and Graphics'' by John Maindonald (PDF [702kB], data sets and scripts are available at JM's homepage). you can get from a CRAN mirror. Regards Ross Darnell -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
You can try something like: x <- rnorm(100) y <- rnorm(100) plot(x) points(y, col = "Red") Cheers, Ko-Kang Wang> > From: Justin Fay <jcfay at lbl.gov> > Date: 2001/11/16 Fri AM 09:49:29 GMT+12:00 > To: r-help at stat.math.ethz.ch > Subject: [R] two plots in one frame > > I would like to plot two different scatterplots in the same frame (say with > different colors) but everytime plot is called a new frame is created. Is > there a way around this? > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >----------------------------------- Ko-Kang Kevin Wang Statistical Analysis Division Leader Software Developers' Klub (SDK) University of Auckland New Zealand -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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, 15 Nov 2001, Justin Fay wrote:> I would like to plot two different scatterplots in the same frame (say with > different colors) but everytime plot is called a new frame is created. Is > there a way around this?if, say, you want to plot 2 sets of y's against the same x, the following: plot(x,y1,ylim=range(c(y1,y2))) points(x,y2,pch=17) makes sure that all the data from y2 are displayed in the plot. If you don't specify the 'ylim=...' option, you won't get all the data in if some values of y2 are outside the range of y1. pch=17 tells it to use a different symbol (the default symbol is a circle, and pch=17 is a triangle). daver +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |David Richmond It works on a | + Dept. of Sociology complex scientific + |Saint Mary's College principle, known as | + Notre Dame, IN 46556 "pot luck." + |219-284-4517 - The Doctor | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Achim Zeileis <zeileis at ci.tuwien.ac.at> writes:>Justin Fay wrote: >> >> I would like to plot two different scatterplots in the same frame (say with >> different colors) but everytime plot is called a new frame is created. Is >> there a way around this? > >try points() >or par(new=TRUE)You might get an axes scaling problem if the range of the two datasets are different. To get over this set xlim and ylim on the first call to plot ... something like: plot(x1, y1, xlim = c(min(x1, x2), max(x1, x2)), ylim = c(min(y1, y2), max(y1, y2)), col = "red") points(x2, y2, col = "blue") You could replace min() and max() with range(). Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._