[R] two graphs 1 x-axis

Philipp Pagel p.pagel at wzw.tum.de
Fri Oct 16 12:39:02 CEST 2009


On Fri, Oct 16, 2009 at 12:22:06PM +0200, Duijvesteijn, Naomi wrote:
> I have a question concerning plotting graphs.
> Here an example dataset
> 
> 
> a<-c(1,2,3,4,5,6)
> b<-c(3,5,4,6,1,1)
> c<-c(1,1,1,1,1,1)
> d<-as.data.frame(cbind(a,b,c))
> plot.new()
> plot(d$a, d$b, col="red")
> par(new=TRUE)
> plot(d$a,d$c, col="red", pch="|")
> 
> What I would want is to plot de second plot under the first plot. So
> not in the the first plot. There is a way to divide your graph in 2
> or 3 parts and use the same x-axis but I do not seem to get it
> right. Could somebody help me out?

Yes, use something alng these lines:

par(mrfow=c(2,1)) 
plot(d$a, d$b, col="red")
plot(d$a, d$c, col="red", pch="|")

As both plots use the same data for X you are set. If you need to
force two datasets with different x-ranges into the same range, you
can use the xlim parameter to define the desired range.

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/




More information about the R-help mailing list