On Friday 06 August 2004 04:16, Joris DeWolf wrote:
> Hi,
>
> I have a lattice xyplot that contains panels according to FactorA,
> and curves for the 2 levels of Factor B within a panel.
> I try to add text in the panels of a lattice graph. I suppose I have
> to write a custom function (panel.txt).
> What I really would like is to adapt the text in the panel according
> to the levels of FactorA.
> In the manuals, I find examples for the strips using which.given and
> which.panel. But this does not work for the panels...
>
> Can Anybody give a hint? Thanks
> Joris
>
> I work with R 1.9.1 under Linux
>
>
> panel.txt = function(sometxt,x,y,...){
> grid.text(sometxt,x,y)
> }
>
> xyplot(data = Pdata, P ~ DAS | FactorA,
> groups = FactorB,
> type ="s",
> col = c("red","blue"),
> panel = function(x,y,...){
> panel.abline(h = 100, lty = 5, lwd =0.5, col = "darkgrey")
> panel.txt(mytext, 0.2, 0.8)
> }
As described in ?xyplot under the entry for 'panel', your panel function
can have an argument called panel.number which would index the levels
of the conditioning variable (or combinations thereof if there are more
than one). e.g.,
panel = function(x,y, panel.number, ...){
cat(paste("In panel", panel.number, "\n"))
panel.abline(h = 100, lty = 5, lwd =0.5, col = "darkgrey")
panel.txt(mytext, 0.2, 0.8)
}
Deepayan
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html