[R] lattice question: removing strips
Duncan Mackay
dulcalma at bigpond.com
Mon Feb 10 15:02:07 CET 2014
Hi Martin
If you only had 1 strip then strip = FALSE would suffice.
With 2 I think you are getting into the realm of strip.default because of the first 2 arguments
strip.default(which.given, which.panel, ....)
and having to modify it
An easy solution is
library(latticeExtra)
useOuterStrips(strip = FALSE,
xyplot(y ~ x | f1 + f2, data=data, strip = FALSE)
)
and to change the strip background to blank or whatever colour
useOuterStrips(strip = FALSE,
xyplot(y ~ x | f1 + f2, data=data, strip = FALSE,
par.settings = list(strip.background = list(col = "transparent"))
)
)
you can format strip.left in the useOuterStrips function. See
?latticeExtra::useOuterStrips
for details
And now to bed
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Martin Ivanov
Sent: Monday, 10 February 2014 22:13
To: Pascal Oettli
Cc: r-help at r-project.org
Subject: Re: [R] lattice question: removing strips
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
>
______________________________________________
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.
More information about the R-help
mailing list