How do you obtain two plots on the same figure? for example plot(rnorm(100) plot(rnorm(100),type="l") -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
In fact my question is more general perhaps this example is better x and y are some variables hist(x) hist(y) my question is how one can get both histograms in the same figure so that they can cross each others. This command exist under matlab it is hold on. Torsten Hothorn a ?crit:> On Tue, 14 Nov 2000, Meriema Belaidouni wrote: > > > How do you obtain two plots on the same figure? > > for example > > plot(rnorm(100) > > plot(rnorm(100),type="l") > > Does > > x <- rnorm(100) > plot(x) > lines(x) # or/and ... > points(x, pch=5) > > do what you want? > > Torsten > > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > > 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Do you want two plots plotted on top of each other (use par(new=TRUE)) or next two each other (par(mfrow=c(2,1)) or par(mfcol=c(2,1)))? On Tue, 14 Nov 2000, Meriema Belaidouni wrote:> How do you obtain two plots on the same figure? > for example > plot(rnorm(100) > plot(rnorm(100),type="l") > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- 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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, I am wondering would it not be easier to fit curves to the histograms and then plot these curves. These are not as accurate but it is easier to compare the results. For instance the following function has as an input two measured data sets, e.g., plothist(rnorm(500),rnorm(500)) The function takes these data sets and fits a normal function to each of them and also scales the function to the dataset size. It then plots the fitted curves (It is a little messy as I had only intended to use it to fit one data set at a time but I am sure that someone should should be able to modify it easily). function (input1,input2) { # Calculate Stats for input1 sigma1<-sd(input1) mu1<-mean(input1) xlow1<-(min(input1)) - 2*sigma1 xhigh1<-(max(input1)) + 2*sigma1 # Calculate Stats for input2 sigma2<-sd(input2) mu2<-mean(input2) xlow2<-(min(input2)) - 2*sigma2 xhigh2<-(max(input2)) + 2*sigma2 # Calculate scaling for fit1 hist.obj1<-hist(input1,xlim=range(xlow1,xhigh1),plot=F) k1<-hist.obj1$counts[1]/hist.obj1$intensities[1] # Calculate scaling for fit2 hist.obj2<-hist(input2,xlim=range(xlow2,xhigh2),plot=F) k2<-hist.obj2$counts[1]/hist.obj2$intensities[1] # Calculate fit1 normal.fit1 <- function(x) k1/(sqrt(2*3.142)*sigma1)*exp(0.5*(-(x-mu1)**2)*sigma1**-2) # Calculate fit2 normal.fit2 <- function(x) k2/(sqrt(2*3.142)*sigma2)*exp(0.5*(-(x-mu2)**2)*sigma2**-2) # Plot measured and fitted data hist(input1,xlim=range(xlow1,xhigh1),freq=T) #hist(input2,xlim=range(xlow1,xhigh1),freq=T,col="blue") curve(normal.fit1,add=T,xlow1,xhigh1,col="red") curve(normal.fit2,add=T,xlow2,xhigh2,col="blue") box() } ************************************************************** Dermot MacSweeney NMRC, Email: dsweeney at nmrc.ucc.ie Lee Maltings, Tel: +353 21 904178 Prospect Row, Fax: +353 21 270271 Cork, WWW: http://nmrc.ucc.ie Ireland ************************************************************** -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._