[R] Lattice Groups

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Apr 8 21:07:20 CEST 2009


On Wed, Apr 8, 2009 at 10:36 AM, Lyman, Mark <Mark.Lyman at atk.com> wrote:
> I don't understand your first question, but, since no one else has
> responded I can answer your second question. panel.bwplot, unlike
> panel.xyplot doesn't use panel.superpose when groups is not NULL. In
> order to get an analogous result you need to specify that you want to
> use panel.superpose.
>
> cols <- c("Sepal.Width", "Petal.Length", "Petal.Width")
> stackedData <- stack(iris[, cols])
> df <- data.frame(y = stackedData$values, x = rep(iris$Species, 3), which
> = gl(3, nrow(iris)))
>
> bwplot(y ~ x:which, data = df, groups = which, panel=panel.superpose,
> panel.groups = panel.bwplot)
>
> If you don't like the default colors, you can set the fill colors with
> par.settings like:
>
> bwplot(y ~ x:which, data = df, groups = which, panel=panel.superpose,
> panel.groups = panel.bwplot,
> par.settings=list(superpose.symbol=list(fill=2:4)))

And to answer the first question: using panel.superpose hijacks the
parameters of the median spot, but they can be supplied explicity:

bwplot(y ~ x:which, data = df, groups = which, panel=panel.superpose,
    panel.groups = panel.bwplot,
    par.settings=list(superpose.symbol=list(fill=2:4)), col = "black", pch = 16)

-Deepayan

>
> Without the groups, the fill colors are controlled like this
> bwplot(y~x:which, data = df,
> par.settings=list(box.rectangle=list(fill=2:4)))
>
> Although if you have groups, using the groups argument is probably
> better.
>
> Mark Lyman
>
>
> Message: 41
> Date: Tue, 7 Apr 2009 10:50:33 +0100
> From: Richard Weeks <dickyweeks at hotmail.com>
> Subject: [R] Lattice Groups
> To: <r-help at r-project.org>
> Message-ID: <BLU138-W2277550025ED688AAE0C91DC850 at phx.gbl>
> Content-Type: text/plain
>
>
> Hi all,
>
>
>
> I'm trying to achieve a few things using the lattice package but am
> failing miserably.
>
> I am plotting side by side box plots and using a grouping variable, e.g.
>
>
>
> cols <- c("Sepal.Width", "Petal.Length", "Petal.Width")
> stackedData <- stack(iris[, cols])
> df <- data.frame(y = stackedData$values, x = rep(iris$Species, 3), which
> = gl(3, nrow(iris)))
>
> bwplot(y ~ x:which, data = df, group = which, panel.groups =
> panel.bwplot)
>
>
>
> My questions are
>
> 1) How am I able to retain the median spot in the boxes?
>
> 2) How can I change the fill using the par.settings argument rather than
> fill =1:3 say?
>
>
>
> Best wishes,
>
>
>
> Biff
>
> ______________________________________________
> 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