Hi Folks, The following gives me the exact plot I want using trellis. xyplot(V56 ~ V12 | subset(frequency, V17 < 12000) , data=kdata, ylab="Fine Structure Depth [dB]", xlab="QSIN score", panel=function(x,y,...) { panel.xyplot(x[HL=="N"],y[HL=="N"], pch=16,col="green") panel.xyplot(x[HL=="SN"],y[HL=="SN"],pch=16, col="red") panel.lmline(x[HL=="N"],y[HL=="N"], col="green") panel.lmline(x[HL=="SN"],y[HL=="SN"], col="red") } ) Now I want to add to each panel by writing the result of cor(V56[HL=="N"],V12[HL=="N"], use="complete") cor(V56[HL=="SN"],V12[HL=="SN"], use="complete") in the specific colors. I have tried things such as: panel.text(4,20,round(cor(V56[HL=="N"],V12[HL=="N"], use="pairwise.complete"),digits=3),col="green4") But this does not seem to compute correlation based on the grouping variable in each panel. I am not sure that I have given you adequate information. Any help will be much appreciated. Regards, Sumit [[alternative HTML version deleted]]