[R] lattice question: removing strips
Martin Ivanov
tramni at abv.bg
Mon Feb 10 13:12:45 CET 2014
Dear Pascal,
Thank You very much for Your reply. Here is a minimal working example:
library(lattice);
# this is with both strips plotted:
data <- data.frame(x=1:5, y=6:10, f1=c("a1", "a1", "a1", "a2", "a3"), f2=c("b1", "b2", "b2", "b1", "b2"));
p <- xyplot(y ~ x | f1 + f2, data=data)
print(p);
# and this is my attempt to only plot the strips for the second conditioning variable, i.e. for f2:
my.strip <- function(which.given, strip.levels, ...) {
if(which.given == 1) {
return(FALSE);
}
else {
strip.default(which.given=which.given, strip.levels=c(TRUE, FALSE), ...);
}
}
p1 <- xyplot(y ~ x | f1 + f2, data=data, strip=my.strip)
print(p1);
#As You can see, here I do not get the strips for f1 potted, but there is an empty space below
the strips for f1, which I cannot get rid of. I only want to show the strips for f2. Directly
below them I want to see the panels themselves, instead of an empty space for the missing f1 strips.
Any suggestions?
Best regards,
Martin
>-------- Оригинално писмо --------
>От: Pascal Oettli
>Относно: Re: [R] lattice question: removing strips
>До: Martin Ivanov
>Изпратено на: Понеделник, 2014, Февруари 10 12:56:21 EET
>
>
>Hello,
>
>Please provide a "commented, minimal, self-contained, reproducible
>code", as requested.
>
>Regards,
>Pascal
>
>On 10 February 2014 19:48, Martin Ivanov wrote:
>> Dear lattice users,
>>
>> I am trying to produce a lattice graph with two conditioning variables.
>> My problem is that I only want to show the strips for the levels of the second conditioning variable.
>> I want to remove the strips for the levels of the first conditioning variable.
>> I tried with the strip function, but if I tell it to return FALSE or NULL whenever which.given == 1, I just get empty space below the strips for the second conditioning variable. And I want to remove that space altogether. Is it somehow achievable in lattice?
>>
>> I also tried setting layout.heights$strip to 0 when which.given == 1, but it seems to only work globally, so either
>> the strips for both conditioning variables vanish, or both are present.
>>
>> Any suggestions will be appreciated.
>>
>>
>> Best regards,
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>
>
>
>--
>Pascal Oettli
>Project Scientist
>JAMSTEC
>Yokohama, Japan
>
More information about the R-help
mailing list