Please look at the panel.bwplot.intermediate.hh in the HH package.  This
example is on the
?position
help page, also in the HH package.
If you don't have HH yet, you can get it with
install.packages("HH")
library(HH)

The full example is
require(HH)
## boxplots coded by week
tmp <- data.frame(Y=rnorm(40, rep(c(20,25,15,22), 10), 5),
                  week=ordered(rep(1:4, 10)))
position(tmp$week) <- c(1, 2, 4, 8)
bwplot(Y ~ week, horizontal=FALSE,
       scales=list(x=list(limits=c(0,9),
                   at=position(tmp$week),
                   labels=position(tmp$week))),
       data=tmp, panel=panel.bwplot.intermediate.hh)


On Tue, Oct 12, 2010 at 11:55 AM, Mehrdad Shamsi
<mehrdad.sha...@oicr.on.ca>wrote:

> Hi,
> I posted this message on R-devel, but it seems to be more suitable for
> R-help. So I post it here again.
>
> I'm trying to produce colored boxplots using lattice::bwplot function. I
> need to plot each boxplot in the panel with a specific color. Naturally, I
> used a vector of colors and expected to see colored boxplots. Although the
> boxplots were colored, the color of whiskers and the boxes  do not match.
> Here is an example:
>
> d = data.frame(y = rnorm(100), x=1:4)
> box.color <- c('red','blue','black', 'green')
> bwplot(y~x,
>        data=d,
>        horizontal=FALSE,
>        par.settings = list(
>        box.rectangle = list(col = box.color),
>        box.umbrella = list(col = box.color)
>        )
> )
>
> I went through the bwplot.panel to figure out what the problem was. It
> seems that bwplot.panel function is implemented with the assumption that
> box.rectangle$col and box.umberella$col are not vectors. It would be nice if
> bwplot.panel could accept vector of colors.
>
> I use R2.11-x64 on a Windows XP machine. The lattice package version is
> lattice_0.19-13.
>
> --Thanks
>
> -- M.S.
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

        [[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.

Reply via email to