[R] Superimposing graphs

Duncan Mackay dulcalma at bigpond.com
Tue Aug 12 02:22:33 CEST 2014


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.



More information about the R-help mailing list