[R] Lattice: shifting strips to left of axes

Michael Hoffman b3i4old02 at sneakemail.com
Tue Jul 3 17:21:56 CEST 2007

deepayan.sarkar at gmail.com wrote:
> 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)

Thanks for the response.

Not looking like a real strip is fine. What I want is essentially a 
secondary ylab for each row, and don't care about niceties such as 
shingle markings (I should have made the conditional factor(cyl) in the 
above plot).

But it looks like the legend goes to the left of the plot's ylab, and 
what I really want is for the secondary ylab to be between the primary 
ylab and the panel. So looks like I would have to eliminate the primary 
ylab from being drawn automatically and draw it myself in the legend? 
And I think I would have to manually calculate the panel heights as 
well, right? I don't see a way for the legend to get this out of the 
trellis object.

> 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)))

This seems a lot easier.

More information about the R-help mailing list