0

I'm looking to change the colour of a line and add an additional line in an xy plot

Distance<-c(1,2,3,4,5,6,7,8,9,10,11,12,13)
PAR<-c(1,3,5,9,15,12,11,6,5,4,3,1,0.5)

Function1<-function(Distance,param){
  abs(param[1])*Distance*param[2]*exp(1)*exp(-(Distance*param[2]))
}

Function2<-function(Distance,param){
param[1]+param[2]*Distance
}

e<-c(0.05,0.1)

f<-c(4,0.9)

p1<-xyplot(PAR~Distance,data=Control,     
           xlab="Exponential Model", ylab=expression("C=1"),
           xlim=c(0,20),
           ylim=c(0,0.1),
           col = ("cornsilk3"),
           grid=(TRUE),
           panel=function(x,y,...){
             panel.xyplot(x,y,...)
             panel.lines(x,(Function1(x,1,e))))}

So basically i'd like to add an additional panel line for function2 paired with the f list of parameters and have them as 2 different colours so i can differentiate between them.

AW1991
  • 61
  • 5

1 Answers1

0

Simply add another line panel.lines(x,(Function2(x,f)),col="red")

Note also, Function1(x,1,e) should be Function1(x,e) I think.

Your sample data is not in a data.frame Control. And you'll probably need to adjust ylim.

And your final )} should be }).

DaveTurek
  • 1,297
  • 7
  • 8