On 7/11/07, Jonathan Williams <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I'm having some trouble understanding the intricacies of panel
> functions.  I wish to create three side-by-side graphs, each with
> different data-- so far, so good: I rbind() the data, add a column of
> subscripts as a conditioning variable, load up the lattice package,
> specify either a c(3,1) 'layout' or work through 'allow.multiple' and
> 'outer' and I'm good to go.
>
> But now I wish to add three rectangles to each plot, which will be in
> different places on each panel, and I'm terribly stuck.  I can guess
> this requires defining a panel function on the fly, but none of my
> attempts are working.  Suggestions?

You haven't told us what determines the rectangles (only that they are
different in each panel). If they are completely driven by panel data,
here's an example:

panel.qrect <-
    function(x, y, ...)
{
    xq <- quantile(x, c(0.1, 0.9))
    yq <- quantile(y, c(0.1, 0.9))
    panel.rect(xq[1], yq[1], xq[2], yq[2],
               col = "grey86", border = NA)
    panel.xyplot(x, y, ...)
}

xyplot(Sepal.Length ~ Sepal.Width | Species, iris,
       panel = panel.qrect)

If the rectangles are somehow determined externally, you probably want
to use one of the accessor functions described in help(panel.number).
There are good and bad (i.e. less robust) ways to use these, but we
need to know your use case before recommending one.

-Deepayan

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to