[R] panel.text question

Henrique Dallazuanna wwwhsd at gmail.com
Thu Sep 24 20:18:21 CEST 2009


Try this:

xyplot(y ~ x | a,
   panel=function(x, y, subscripts, ...){
       panel.loess(x, y)
       panel.text(0, 2,
label=c('best','better','bad','worst')[tail(subscripts, 1)/100])
   })

On Thu, Sep 24, 2009 at 2:45 PM, Osman Al-Radi <osman.al.radi at gmail.com> wrote:
> Dear R-help,
>
> I would like to add text to each of four panels in a plot generated by
> xyplot in lattice library. A sample code is given below, the plot generated
> has the first label repeated in all panels!
>
> How can I get the labels to be different in each panel?
>
> library(lattice)
> x <- rnorm(400)
> y <- rnorm(400)
> a <- gl(4, 100)
>
> xyplot(y~x|a,
>    panel=function(...){
>        panel.loess(...)
>        panel.text(0,2,label=c('best','better','bad','worst'))})
>
> Thanks
>
> Osman
>
>
>
> Osman O. Al-Radi, MD, MSc, FRCSC
> Staff Cardiovascular Surgeon
> Co-medical director, Tissue Bank
> The Hospital for Sick Children
> University of Toronto, Canada
>
>        [[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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list