Hi! I want to display 2 graphs with different number of data points on the x-axis. The code below scales them so it seems that testtwo has the same number of data points as testone. How can I fix that? thanks. z<-1:50; x<-1:100; plot(x,testone,type="l",xlab="",ylab="",main="",lty=4,axes=FALSE,ylim=c(-1.0,1.0),cex=1); par(new=TRUE); plot(z,testtwo,type="l",xlab="",ylab="",main="",lty=1,col="red",axes=FALSE,ylim=c(-1.0,1.0),cex=1); xlabels<-x*10; axis(1,1:100,xlabels); axis(2); box(); -- myriam -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Myriam Abramson wrote:> > Hi! > > I want to display 2 graphs with different number of data points on the > x-axis. The code below scales them so it seems that testtwo has the > same number of data points as testone. How can I fix that? thanks. > > z<-1:50; > x<-1:100; > plot(x,testone,type="l",xlab="",ylab="",main="",lty=4,axes=FALSE,ylim=c(-1.0,1.0),cex=1); > par(new=TRUE); > plot(z,testtwo,type="l",xlab="",ylab="",main="",lty=1,col="red",axes=FALSE,ylim=c(-1.0,1.0),cex=1); > xlabels<-x*10; > axis(1,1:100,xlabels); > axis(2); > box(); > --You can additionally set xlim, but the better way is to add "testtwo" with lines() or points(): z <- 1:50 x <- 1:100 plot(x,testone,type="l",xlab="",ylab="",main="",lty=4,xaxt="n",ylim=c(-1.0,1.0),cex=1) lines(z, testtwo, lty=1, col="red", cex=1) xlabels <- x*10 axis(1,1:100,xlabels) Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello Myriam, use lines for the second plot ... plot(x,testone,.....) lines(z,testtwo,lty=4,col='red') xlabel..... .... or add NA's two testtwo and make a matrix out oft testone and testtwo and use matplot d <- cbind(testone,c(testtwo,rep(NA,length(testone)-length(testtwo)))) matplot(d,typ='l') gruess joerg Myriam Abramson wrote:> > Hi! > > I want to display 2 graphs with different number of data points on the > x-axis. The code below scales them so it seems that testtwo has the > same number of data points as testone. How can I fix that? thanks. > > z<-1:50; > x<-1:100; > plot(x,testone,type="l",xlab="",ylab="",main="",lty=4,axes=FALSE,ylim=c(-1.0,1.0),cex=1); > par(new=TRUE); > plot(z,testtwo,type="l",xlab="",ylab="",main="",lty=1,col="red",axes=FALSE,ylim=c(-1.0,1.0),cex=1); > xlabels<-x*10; > axis(1,1:100,xlabels); > axis(2); > box(); > -- > myriam > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Joerg Maeder .:|:||:..:.||.:: maeder at atmos.umnw.ethz.ch Tel: +41 1 633 36 25 .:|:||:..:.||.:: http://www.iac.ethz.ch/staff/maeder PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH) ETH Z?RICH Switzerland -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 20 Mar 2002, Myriam Abramson wrote:> > Hi! > > I want to display 2 graphs with different number of data points on the > x-axis. The code below scales them so it seems that testtwo has the > same number of data points as testone. How can I fix that? thanks. > > > z<-1:50; > x<-1:100; > plot(x,testone,type="l",xlab="",ylab="",main="",lty=4,axes=FALSE,ylim=c(-1.0,1.0),cex=1); > par(new=TRUE); > plot(z,testtwo,type="l",xlab="",ylab="",main="",lty=1,col="red",axes=FALSE,ylim=c(-1.0,1.0),cex=1); > xlabels<-x*10; > axis(1,1:100,xlabels); > axis(2); > box();Here are 2 things to try: z<-1:50; x<-1:100; plot(x,testone,type="l",xlab="",ylab="",main="",lty=4,axes=FALSE, ylim=c(-1.0,1.0), cex=1) axis(2) par(new=TRUE); plot(z,testtwo,type="l",xlab="",ylab="",main="",lty=1,col="red",axes=FALSE, ylim=c(-1.0,1.0), cex=1, xlim=range(x)) xlabels<-x*10; axis(1,1:100,xlabels); axis(4); box(); or z<-1:50; x<-1:100; plot(x,testone,type="l",xlab="",ylab="",main="",lty=4, axes=FALSE, ylim=c(-1.0,1.0), cex=1) par(new=TRUE); points(z,testtwo,type="l",xlab="",ylab="",main="",lty=1,col="red",axes=FALSE, ylim=c(-1.0,1.0), cex=1) xlabels<-x*10; axis(1,1:100,xlabels); axis(2); box(); When the par option xaxs="d" is implemented, then that will be a third option. -- Greg Snow, PhD Office: 223A TMCB Department of Statistics Phone: (801) 378-7049 Brigham Young University Dept.: (801) 378-4505 Provo, UT 84602 email: gls at byu.edu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._