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

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Jan 5 07:36:54 CET 2011


On Tue, Jan 4, 2011 at 9:32 PM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:
>
>
> 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.

You can also use 'xlab.top' instead of 'main' with the version of
lattice available at r-forge (to be uploaded to CRAN soon-ish).

-Deepayan



More information about the R-help mailing list