[R] two graphs 1 x-axis

Jim Lemon jim at bitwrit.com.au
Fri Oct 16 12:35:56 CEST 2009


On 10/16/2009 09:22 PM, Duijvesteijn, Naomi wrote:
> Dear R-people
>
> 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?
>    
Hi Naomi,
Try this:

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

You may want to change the margins (par(mar=c(...)) to get the spacing 
the way you want it.

Jim




More information about the R-help mailing list