I had a similar problem and found when looking inside one of the lattice functions that the legend colours are controlled by the superpose series eg superpose.line, superpose.polygon etc
in trellis.par.set/get or par.settings

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au



At 02:28 14/08/2013, you wrote:
Content-Type: text/plain
Content-Disposition: inline
Content-length: 3675

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 <
anna.zakris...@su.se> 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: anna.zakris...@su.se
> Tel work: +49-(0)3091541281
> Mobile: +49-(0)15777374888
> LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
>
> ><((((º>`•. . • `•. .• `•. . ><((((º>`•. . • `•. .• `•. .><((((º>`•. . •
> `•. .• `•. .><((((º>
>
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@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.
>
>


--
Kevin Wright

        [[alternative HTML version deleted]]


______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to