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