[R] two graphs 1 x-axis

Felipe Carrillo mazatlanmexico at yahoo.com
Fri Oct 16 16:18:01 CEST 2009


You can use ggplot2.

library(ggplot2)
a<-c(1,2,3,4,5,6)
 b<-c(3,5,4,6,1,1)
 c<-c(1,1,1,1,1,1)
dframe = data.frame(a,b,c);dframe
melt.dframe <- melt(dframe, id= "a");melt.dframe
qplot(a,value,data=melt.dframe) + facet_grid(variable~.,scales="free")

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA


--- On Fri, 10/16/09, Duijvesteijn, Naomi <Naomi.Duijvesteijn at ipg.nl> wrote:

> From: Duijvesteijn, Naomi <Naomi.Duijvesteijn at ipg.nl>
> Subject: [R] two graphs 1 x-axis
> To: "r-help at r-project.org" <r-help at r-project.org>
> Date: Friday, October 16, 2009, 3:22 AM
> 
> 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?
> 
> Thanks in advance!
> 
> Regards,
> Naomi
> 
> 
> 
> 
> 
> 
> Disclaimer: De informatie opgenomen in dit bericht (en
> bijlagen) kan vertrouwelijk zijn en is uitsluitend bestemd
> voor de geadresseerde(n). Indien u dit bericht ten onrechte
> ontvangt, wordt u geacht de inhoud niet te gebruiken, de
> afzender direct te informeren en het bericht te vernietigen.
> Aan dit bericht kunnen geen rechten of plichten worden
> ontleend.
> 
> ------------------------------------------------------------------------------------------------------------------------------------------
> 
> Disclaimer: The information contained in this message may
> be confidential and is intended to be exclusively for the
> addressee. Should you receive this message unintentionally,
> you are expected not to use the contents herein, to notify
> the sender immediately and to destroy the message. No rights
> can be derived from this message.
> 
> Please consider the environment before printing this email
> 
> 
> -----Inline Attachment Follows-----
> 
> ______________________________________________
> R-help at r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>




More information about the R-help mailing list