Re: [R] Lattice: hiding only some strips

From: Michael Hoffman <b3i4old02_at_sneakemail.com>
Date: Sat, 23 Jun 2007 02:09:59 +0100

Deepayan Sarkar wrote:
> On 6/22/07, Michael Hoffman <b3i4old02@sneakemail.com> wrote:

>> I am using R 2.4.0 and lattice to produce some xyplots conditioned on a
>> factor and a shingle. The shingle merely chops up the data along the
>> x-axis, so it is easy to identify which part of the shingle a panel is
>> in by looking at the x-axis markings. I only want to have a strip at the
>> top for the factor.
>>
>> Is this possible? I looked into calculateGridLayout() and it seems to me
>> that there isn't an easy way to do it without rewriting that function
>> (and others).

>
> It's nowhere near that complicated, you just need to write your own
> strip function. E.g.,
>
> mtcars$HP <- equal.count(mtcars$hp)
>
> xyplot(mpg ~ disp | HP + factor(cyl), mtcars,
> par.strip.text = list(lines = 0.5),
> strip = function(which.given, which.panel, ...) {
> if (which.given == 2)
> strip.default(which.given = 1,
> which.panel = which.panel[which.given],
> ...)
> })

Thank you for this response. But it looks like I poorly specified the problem. I only want to have a strip at the very top of the plot, not at the top of each panel.

You can probably understand why I want this better if we take your example and swap the givens around:

xyplot(mpg ~ disp | factor(cyl) * HP, mtcars,

        par.strip.text = list(lines = 0.5),
        strip = function(which.given, which.panel, ...) {
            if (which.given == 1)
                strip.default(which.given = 1,
                              which.panel = which.panel[which.given],
                              ...)
        })

So now I have 4, 6, and 8 at the top of every row of panels as a label for cyl. But I don't need that--really I only need 4, 6, and 8 at the very top (or bottom) of the plot, just like with default settings I only get the axis labels at the top and bottom of the plot, not duplicated for every panel.

What I want is to draw strips at the very top of the plot and not to draw strips that are between panels.

Can this be done?



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 23 Jun 2007 - 02:34:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 23 Jun 2007 - 03:32:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.