Thank you very much Kevin Wright! you managed to understand my somewhat cryptic
question.
Now I have a perfect graph. I changed the my.theme to:
my.theme <- list(
box.umbrella = list(col = "black"),
box.rectangle = list(col="black"),
box.dot = list(col = "black", pch = 3, cex=2),
plot.symbol = list(cex = 1, col = 1, pch= 0), #outlier size and color
par.xlab.text = font.settings,
par.ylab.text = font.settings,
axis.text = font.settings,
#strip.shingle=list(col=c("black","white")),
superpose.symbol=list(fill=c("gray","white")), # boxplots
#superpose.fill=list(col=c("black","white")),
superpose.polygon=list(col=c("gray","white")), # legend
par.sub=font.settings)
as adviced by you.
With kind regards
Anna Zakrisson Braeunlich
PhD student
Department of Ecology, Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden/Sverige
Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland
E-mail: [email protected]
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
><((((º>`. . `. . `. . ><((((º>`. . `. . `. .><((((º>`. . `. .
>`. .><((((º>
________________________________
From: Kevin Wright [[email protected]]
Sent: 13 August 2013 18:28
To: Anna Zakrisson Braeunlich
Cc: [email protected]
Subject: Re: [R] Lattice: bwplot - changing box colors in legend and plot when
using panel.groups = function... and panel = panel.superpose
I think I understand your question. You need to make sure that you are setting
the right parameters in your theme. Use trellis.par.get() to have a look at
the MANY possible settings. For example, in your case, to have the boxplots
and rectangles be the same color:
my.theme <- list(
box.umbrella = list(col = "black"),
box.rectangle = list(fill= rep(c("black", "black"),2)),
box.dot = list(col = "black", pch = 3, cex=2),
plot.symbol = list(cex = 1, col = 1, pch= 0), #outlier size and color
par.xlab.text = font.settings,
par.ylab.text = font.settings,
axis.text = font.settings,
#strip.shingle=list(col=c("red","blue")),
superpose.symbol=list(fill=c("red","blue")), # boxplots
#superpose.fill=list(col=c("red","blue")),
superpose.polygon=list(col=c("red","blue")), # legend
par.sub=font.settings)
Kevin Wright
On Tue, Aug 13, 2013 at 9:00 AM, Anna Zakrisson Braeunlich
<[email protected]<mailto:[email protected]>> wrote:
Hi,
Yes, I have searched stack overflow.
My issue is to simply change coloring in boxes and legend in my bwplot. I have
done this many times in lattice, but now I have been tweaking the plot somewhat
and I can no longer apply the color changes.
I would really appreciate some help.
A. Zakrisson
Here is some dummy data and my script:
mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)),
factor2 = factor(rep(c(1:2), each = 16)),
var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
sd = rep(c(1, 2, 3), each = 20)))
font.settings <- list( font = 1, cex = 1, fontfamily = "serif")
my.theme <- list(
box.umbrella = list(col = "black"),
box.rectangle = list(fill= rep(c("black", "black"),2)),
box.dot = list(col = "black", pch = 3, cex=2),
plot.symbol = list(cex = 1, col = 1, pch= 0), #outlier size and color
par.xlab.text = font.settings,
par.ylab.text = font.settings,
axis.text = font.settings,
par.sub=font.settings)
bwplot(var1 ~ factor1, data = mydata, groups = factor2,
box.width = 1/3, #width of the boxes
auto.key = list(points = FALSE,
rectangles = TRUE, space = "right",
title="Year", cex.title=1),
panel = panel.superpose,
ylab = "var1",
xlab="factor1",
par.settings = my.theme,
panel.groups = function(x, y, ..., group.number) {
panel.bwplot(x + (group.number-1.8)/3, y, ...)
})
Anna Zakrisson Braeunlich
PhD student
Department of Ecology, Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden/Sverige
Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland
E-mail: [email protected]<mailto:[email protected]>
Tel work: +49-(0)3091541281<tel:%2B49-%280%293091541281>
Mobile: +49-(0)15777374888<tel:%2B49-%280%2915777374888>
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
><((((º>`. . `. . `. . ><((((º>`. . `. . `. .><((((º>`. . `. .
>`. .><((((º>
[[alternative HTML version deleted]]
______________________________________________
[email protected]<mailto:[email protected]> 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.
--
Kevin Wright
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.