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

Manuel Kunz mjk44 at gmx.ch
Mon Feb 25 16:47:22 CET 2013


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



More information about the R-help mailing list