[R] Lattice: shifting strips to left of axes

Michael Hoffman b3i4old02 at sneakemail.com
Wed Jul 4 12:18:56 CEST 2007


deepayan.sarkar at gmail.com wrote:

> myYlabGrob <-
>     function(..., main.ylab = "") ## ...is lab1, lab2, etc
> {
>     ## you can add arguments to textGrob for more control
>     ## in the next line
>     labs <- lapply(list(...), textGrob, rot=90)
>     main.ylab <- textGrob(main.ylab, rot = 90)
>     nlabs <- length(labs)
>     lab.heights <-
>         lapply(labs,
>                function(lab) unit(1, "grobheight",
>                                   data=list(lab)))
>     unit1 <- unit(1.2, "grobheight", data = list(main.ylab))
>     unit2 <- do.call(max, lab.heights)
>     lab.layout <-
>         grid.layout(ncol = 2, nrow = nlabs,
>                     heights = unit(1, "null"),
>                     widths = unit.c(unit1, unit2),
>                     respect = TRUE)
>     lab.gf <- frameGrob(layout=lab.layout)
>     for (i in seq_len(nlabs))
>     {
>         lab.gf <- placeGrob(lab.gf, labs[[i]], row = i, col = 2)
>     }
>     lab.gf <- placeGrob(lab.gf, main.ylab, col = 1)
>     lab.gf
> }

Wow. I don't think I would have been able to come up with that on my 
own. Thank you!
-- 
Michael Hoffman



More information about the R-help mailing list