Hi
Patrick Giraudoux wrote:> Hi,
>
> I would like to add text in each panel got from the following:
>
> splom(~Cs5bis,
> panel=function(x,y,...){
> panel.xyplot(x,y,...)
> panel.abline(lm(y~x),...)
> })
>
> This could be a correlation coefficient or the statistical significance of
the correlation or both, or a star if p < 0.05, etc...
> The function text() is useless (probably because I cannot pass appropriates
coordinates in each panel). Googling the R-archives, I
> have found only one hint of Andy Liaw relating a rather complex (to me)
script within a home-made panel.myfitline() function.
>
> Is there a simple way to add text in panels created eg with:
>
> panel=function(x,y,...){
> panel.xyplot(x,y,...)
> panel.abline(lm(y~x),...)
> })
text() is useless because splom is a lattice function and lattice is
based on grid. To add text in a panel you could use lattice's ltext(),
but I think the best way would be to use grid.text() as below. This
example draws the correlation coefficient 1mm in from the top-left
corner of the panel.
panel=function(x,y,...){
panel.xyplot(x,y,...)
panel.abline(lm(y~x),...)
grid.text(round(cor(x, y), 2),
x=unit(1, "mm"), y=unit(1, "npc") - unit(1,
"mm"),
just=c("left", "top"))
})
Does that do what you want?
Paul
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/