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)
}
--
======================================================================
Joris De Wolf
CropDesign N.V.
Plant Evaluation Group
Technologiepark 3
B-9052 Zwijnaarde
Belgium
Tel. : +32 9 242 91 55
Fax : +32 9 241 91 73
======================================================================
confidentiality notice:
The information contained in this e-mail is confidential and...{{dropped}}
Deepayan Sarkar
2004-Aug-06 13:22 UTC
[R] Lattice: how to index in a custom panel function?
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
Maybe Matching Threads
- testing two-factor anova effects using model comparison approach with lm() and anova()
- Problem with bargraph.CI in Sciplot package
- How to generate a new factor variable by two other factor variables
- Randomization of a two-way ANOVA?
- difference in order() between Linux and Windows with mixtures of caps and normal letters