Dear all,
When defining explicit keys with xyplot, I have previously used the fill
parameter to set the background colour of point symbols. That's no
longer working for me, and I am wondering whether it's a bug or whether
I've misinterpreted the documentation and have been relying on a feature
wasn't intended. If the latter, can anyone suggest the correct way to do it?
Here's an example of what I am trying to do:
library(lattice)
print(xyplot(y ~ x,
data=data.frame(x=1:10, y=1:10),
key=list(points=list(pch=21,
col="blue",
cex=3,
fill="red"))))
Only the key is of interest here. It doesn't match the data and isn't
meant to.
On R 2.15.2 and lattice 0.20-10 the circle in the key has a blue outline
and a red fill colour. On R 2.15.3 and lattice 0.20-13 the fill is
transparent (or white).
The source code for draw.key looks like it is sill trying to support the
fill option. I have been able to confirm the old behaviour with the old
R and lattice versions on Ubuntu 11.10 and openSUSE 12.2. I have
confirmed the new behaviour with the new versions on Ubuntu 11.10 and
Windows 7.
Many thanks,
Wayne Rochester
CSIRO, Brisbane, Australia
Specifying point symbol fill colour in lattice xyplot keys
2 messages · Wayne Rochester, Duncan Mackay
Hi Wayne
Try this
library(lattice)
xyplot(1:10 ~ 1:10,
par.settings = list(plot.symbol = list(col = "blue",
fill = "red",
cex = 1,
pch = 21)),
type = "p",
key = list(points = list(col = "blue",
fill = "red",
cex = 3,
pch = 21))
)
I sometimes have trouble with passing colours etc to panels and keys
in lattice but this seems to work.
If you have groups change plot.symbol to superpose.symbol
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
At 11:11 12/03/2013, you wrote:
Dear all,
When defining explicit keys with xyplot, I have previously used the
fill parameter to set the background colour of point symbols. That's
no longer working for me, and I am wondering whether it's a bug or
whether I've misinterpreted the documentation and have been relying
on a feature wasn't intended. If the latter, can anyone suggest the
correct way to do it?
Here's an example of what I am trying to do:
library(lattice)
print(xyplot(y ~ x,
data=data.frame(x=1:10, y=1:10),
key=list(points=list(pch=21,
col="blue",
cex=3,
fill="red"))))
Only the key is of interest here. It doesn't match the data and
isn't meant to.
On R 2.15.2 and lattice 0.20-10 the circle in the key has a blue
outline and a red fill colour. On R 2.15.3 and lattice 0.20-13 the
fill is transparent (or white).
The source code for draw.key looks like it is sill trying to support
the fill option. I have been able to confirm the old behaviour with
the old R and lattice versions on Ubuntu 11.10 and openSUSE 12.2. I
have confirmed the new behaviour with the new versions on Ubuntu
11.10 and Windows 7.
Many thanks,
Wayne Rochester
CSIRO, Brisbane, Australia
______________________________________________ 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.