r - Adding additional panel plots to an XY lattice plot -


i'm looking change colour of line , add additional line in 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 i'd add additional panel line function2 paired f list of parameters , have them 2 different colours can differentiate between them.

simply add line panel.lines(x,(function2(x,f)),col="red")

note also, function1(x,1,e) should function1(x,e) think.

your sample data not in data.frame control. , you'll need adjust ylim.

and final )} should }).


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -