[R] Lattice: shifting strips to left of axes

deepayan.sarkar at gmail.com deepayan.sarkar at gmail.com
Tue Jul 3 05:40:55 CEST 2007


On 7/2/07, Michael Hoffman <b3i4old02 at sneakemail.com> wrote:
> Consider this plot:
>
> xyplot(mpg ~ disp | cyl, mtcars, strip=F, strip.left=T, layout=c(1, 3),
>         scales=list(relation="free"),
>         par.settings=list(strip.background=list(col="transparent")))
>
> I want to have the "cyl" strip labels on the left side of the axis. Is
> this possible?

No. (It's possible to have a legend there, which could be used to put
row-specific ylab-s, for example, but it will be hard to make it look
like strips)

> Failing that, is it possible to remove the left axis and display it on
> the right instead, despite relation="free"?

Yes, as long as you are willing to manually manage the space required for it:

xyplot(mpg ~ disp | cyl, mtcars, strip=F, strip.left=T, layout=c(1, 3),
       scales=list(relation="free", y = list(draw = FALSE)),
       axis = function(side, ...) {
           if (side == "right")
               panel.axis(side = "right", outside = TRUE)
           else axis.default(side = side, ...)
       },
       par.settings=
       list(strip.background=list(col="transparent"),
            layout.widths = list(axis.key.padding = 5)))

-Deepayan



More information about the R-help mailing list