Skip to content

Lattice Groups

3 messages · Deepayan Sarkar, Lyman, Mark

#
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)))

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
#
On Wed, Apr 8, 2009 at 10:36 AM, Lyman, Mark <Mark.Lyman at atk.com> wrote:
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
#
I guess I didn't look too closely. I didn't even notice the points were gone. Thanks, Deepayan.

Mark Lyman


-----Original Message-----
From: Deepayan Sarkar [mailto:deepayan.sarkar at gmail.com] 
Sent: Wednesday, April 08, 2009 1:07 PM
To: Lyman, Mark
Cc: r-help at r-project.org; dickyweeks at hotmail.com
Subject: Re: [R] Lattice Groups
On Wed, Apr 8, 2009 at 10:36 AM, Lyman, Mark <Mark.Lyman at atk.com> wrote:
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