Vasudevan, Geetha
2003-Mar-26 18:35 UTC
[R] 2 scatter plots in the same graphic window....
Hello, I am trying to do a scatter plot of x1,y1 and x2,y2 in the same graphics window with diff col/pch values. i cannot get it to do them in the same window. what is the cmd to do this? thanks.
plot() and points(), e.g. x <- matrix(rnorm(300), ncol=3) plot(x[,1],x[,2], pch=1, col="red") points(x[,1],x[,3], pch=2, col="blue") Cheers Henrik Bengtsson Lund University> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of > Vasudevan, Geetha > Sent: den 26 mars 2003 19:35 > To: r-help at stat.math.ethz.ch > Subject: [R] 2 scatter plots in the same graphic window.... > > > Hello, > > I am trying to do a scatter plot of x1,y1 and x2,y2 in the > same graphics window with diff col/pch values. i cannot get > it to do them in the same window. > > what is the cmd to do this? thanks. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help > >
x1 <- 1:9 y1 <- x1 x2 <- x1 y2 <- 9-x1 plot(c(0, 9), c(0, 9), type="n") points(x1, y1, col=1, pch=1) points(x2, y2, col=2, pch=2) Is this what you want? Spencer Graves Vasudevan, Geetha wrote:> Hello, > > I am trying to do a scatter plot of x1,y1 and x2,y2 in the same graphics window with diff col/pch values. i cannot get it to do them in the same window. > > what is the cmd to do this? thanks. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Either n1 <- length(x1) n2 <- length(x2) plot(c(x1,x2),c(y1,y2),col=rep(c(1,2),c(n1,n2)), pch=rep(c(1,2),c(n1,n2)) OR plot(x1,y1,xlim=range(c(x1,x2)),ylim=range(c(y1,y2)),col=1,pch=1) points(x2,y2,col=2,pch=2) will work. Ben Bolker On Wed, 26 Mar 2003, Vasudevan, Geetha wrote:> Hello, > > I am trying to do a scatter plot of x1,y1 and x2,y2 in the same graphics > window with diff col/pch values. i cannot get it to do them in the same > window. > > what is the cmd to do this? thanks. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- 318 Carr Hall bolker at zoo.ufl.edu Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704