[R] lattice: how to "center" a title?

Dieter Menne dieter.menne at menne-biomed.de
Tue Jan 4 17:02:16 CET 2011



mhofert wrote:
> 
> trellis.device("pdf", width = 5, height = 5)
>   print(xyplot(0 ~ 0, main = "This title is not 'centered' for the human's
> eye", scales = list(alternating = c(1,1), tck = c(1,0))))
> dev.off()
> 
> ... the title does not seem to be "centered" for the human's eye [although
> it is centered when the plot (width) is considered with the y-axis label]. 
> 

This is because there is a y label, and centering is on the page (as you
noted). One way around this would be to add a similar padding at the right
side. See the example below, where I have exaggerated the effect. Try a
padding of 5 instead.

Dieter


library(lattice)
trellis.device("pdf", width = 5, height = 5)
trellis.par.set(layout.widths = list(right.padding = 10))
  print(xyplot(0 ~ 0, main = "This title is not 'centered' for the human's
eye", scales = list(alternating = c(1,1), tck = c(1,0))))
dev.off()


-- 
View this message in context: http://r.789695.n4.nabble.com/lattice-how-to-center-a-title-tp3173271p3173800.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list