[R] Xyplot, multi line title via main, all lines left justified

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Sep 10 15:08:50 CEST 2009


On Wed, Sep 9, 2009 at 2:53 PM, Afshartous, David
<DAfshartous at med.miami.edu> wrote:
>
> All,
>
> Below is an xyplot plot with multiple panels and a title produced via main:
>
> library("lattic")
> data.ex = data.frame(y = rnorm(10), t = rep(1:5, 2), group = rep(c(0,1),
> each = 5))
>
> xyplot(y ~ t | as.factor(group), data = data.ex,
>    main = list("Put figure caption here xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>    want this line left justified" ))
>
> I must be mis-interpreting the help description for main under xyplot, and
> the descriptions of just, hjust, and vjust in textGrob, since manipulation
> of these arguments do not seem to produce the desired result of having the
> second line of text left-justified.

This seems to work. You need to choose a suitable value of 'x', as the
default will be to start at the center.

xyplot(y ~ t | as.factor(group), data = data.ex,
       main = textGrob("Put figure caption here
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
want this line left justified", x = 0, hjust = 0))

-Deepayan




More information about the R-help mailing list