[R] Adding lines to complex xyplot

Duncan Mackay dulcalma at bigpond.com
Wed Feb 26 00:28:23 CET 2014


Hi

Once you want to do extra things from the basic you may have to go into the
panel function

xyplot(Observation,IPrediction,
            groups=TreatmentArm,
            col = c(1,2,3),
            cex=0.7,
            panel = function(x,y,...){
                              panel.xyplot(x,y,...)
                              panel.loess(x,y,...)
                              panel.abline(a = 0, b=1) 
                         }
)

For more information see
http://lmdvr.r-forge.r-project.org/figures/figures.html
As you have groups the xyplot arguments may be 

panel = panel.superpose,
panel.groups = function(x,y,...){ 
...
}

You may also be interested in functions in library(latticeExtra) especially
useOuterStrips which avoids double strips by placing the second as a
strip.left

As you have not provided a data set then the information is less

Regards

Duncan

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 Lib Gray
Sent: Wednesday, 26 February 2014 05:34
To: R help
Subject: [R] Adding lines to complex xyplot

Hello,

I am branching out to xyplot for the first time, and I want to layer
several "complex" xyplots. I have tried using panel functions, but so far I
lose all complexity from the scatterplot. I would like to have the
following things in the plot:


1) A plot of observation vs. modeled individual prediction, by treatment
arm, with each subjects' points connected by lines.

xyplot(Observation,IPrediction,groups=TreatmentArm,type="b",col=c(1,2,3),cex
=0.7)


2) Over the former, I would like to add loess smoothers.

I am able to do this in the former with "type=c("b","smooth"), but I would
like to differentiate the smoothers from the rest of the plot with thicker
line widths, and possibly colors.


3) Also over the former, I would like to add a simple abline(0,1).

I can add this, but not also the loess and treatment arm differences with
"panel=function(x,y){}, but cannot figure out to keep all the former
complexity.



Basically, I am trying to recreated the four basic diagnostic plots from
"xpose4", but adding color for treatment differences.

Any help would be appreciated!

	[[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