Skip to content
Back to formatted view

Raw Message

Message-ID: <000701cfb5c3$8358f890$8a0ae9b0$@bigpond.com>
Date: 2014-08-12T00:22:33Z
From: Duncan Mackay
Subject: Superimposing graphs
In-Reply-To: <CAJK=5Yk1hR2Wwa9Fy9itXvYAjFpqhQD6RgS2C7-0i2KuO_O7tw@mail.gmail.com>

Hi

If you want a 1 package and 1 function approach try this

xyplot(conc ~ time | factor(subject, levels = c(2,1,3)), data = data.d,
        par.settings = list(strip.background = list(col = "transparent")),
        layout = c(3,1),
        aspect = 1,
        type   = c("b","g"),
        scales = list(alternating = FALSE),
        panel = function(x,y,...){
        
                  panel.xyplot(x,y,...)

                  # f1<-function(x,v,cl,t)
                  # (x/v)*exp(-(cl/v)*t) f1(0.5,0.5,0.06,t),
                  panel.curve((0.5/0.5)*exp(-(0.06/0.5)*x),0,30)
        
                }
 )

# par.settings ... if you are publishing show text better
# with factor if you want 1:3 omit the levels
# has advantage of doing more things than in groupedData as Doug Bates has
said

Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Naser Jamil
Sent: Monday, 11 August 2014 19:06
To: R help
Subject: [R] Superimposing graphs

Dear R-user,
May I seek your help to sort out a little problem. I have the following
codes
to draw two graphs. I want to superimpose the second one on each of the
first one.

########################################

library(nlme)
subject<-c(1,1,1,2,2,2,3,3,3)
time<-c(0.0,5.4,21.0,0.0,5.4,21.0,0.0,5.4,21.0)
con.cohort<-c(1.10971703,0.54535512,0.07176724,0.75912539,0.47825282,
0.10593292,1.20808375,0.47638394,0.02808967)

data.d=data.frame(subject=subject,time=time,conc=con.cohort)
grouped.data<-groupedData(formula=conc~time | subject, data =data.d)

plot(grouped.data)

##########################################

f1<-function(x,v,cl,t) {
(x/v)*exp(-(cl/v)*t)
                              }
t<-seq(0,30, .01)
plot(t,f1(0.5,0.5,0.06,t),type="l",pch=18, ylim=c(), xlab="time",
ylab="conc")


###########################################

Any suggestion will really be helpful.


Regards,

Jamil.

	[[alternative HTML version deleted]]

______________________________________________
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.