[R] lattice: column titles using xlab.top in multipanel xyplot

Duncan Mackay mackay at northnet.com.au
Mon Feb 25 22:34:59 CET 2013


Hi manuel

Have a look at http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17666.html

Just plugging in your xlabs everything is OK for Deepayan's example

xyplot(1:9 ~ 1:9 | gl(3, 1, 9),
        layout = c(3, 1),
         xlab  = myXlabGrob('Trial number',
                   'Subject number',
                   'Experimental condition'),
        strip = FALSE )

But when I use myXlabGrob to your example the labels are not centered

xyplot(b ~ a | d, e,
        scales = list(y = list(relation = "free", rot = 0)),
        aspect = 1.8, layout = c(3, 1),
        strip = F,
        xlab.top = myXlabGrob('Trial number',
                   'Subject number',
                   'Experimental condition')
        )

Is there something extra you can do with xlab.top?
Otherwise you could do it with grid.text but that is a bit of a pain.

HTH

GTG

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au



At 01:47 26/02/2013, you wrote:
>Hi,
>
>I created a xyplot with a three-column layout. As suggested by 
>Deepayan I tried to put titles to each column by using xlab.top. 
>Unfortunately, as my y-axis scale relation = "free", the column 
>titles are not centered at the three x axes anymore. Any idea how to 
>center the titles?
>
>#Example:
>require(lattice)
>#require(latticeExtra)
>e <- data.frame(a = c(1:30), b = c(1:10,  20:29, 990:999),
>                 d = c(rep("A", 10), rep("B", 10), rep("C", 10)))
>#column titles centered for relation = "same"
>xyplot(b ~ a | d, e,
>        scales = list(y = list(relation = "same", rot = 0)),
>        aspect = 1.8, layout = c(3, 1),
>        xlab.top = c("This is centered", "Bla", "Bla")
>        )
>#column titles not centered for relation = "free"
>xyplot(b ~ a | d, e,
>        scales = list(y = list(relation = "free", rot = 0)),
>        aspect = 1.8, layout = c(3, 1),
>        xlab.top = c("This is not centered", "Bla", "Bla")
>        )
># end of example
>
>Best regards,
>manuel
>
>______________________________________________
>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.



More information about the R-help mailing list