问题
I'm making a plot using xyplot
in lattice
(R 15.2, lattice 0.20-13) in which I have several groups that I would like to distinguish by the shape of the marker. I need to use a downward facing triangle which is only available as a hollow symbol (pch=25
) unlike up triangle which is available as a filled (pch=17
) or hollow (pch=24
) symbol. I can specify both the outline color and the fill color for these symbols in par.settings(superpose.line())
, but when I plot an auto.key
, there is no fill. Is there some way to get the auto.key
to be consistent with the plot symbols?
This is an example of what I'm describing:
data <- data.frame(x_var = rep(1:10, 2), y_var = rnorm(20), group=rep(c(1,2),each=10))
xyplot(y_var ~ x_var, groups=group, data=data,
par.settings=list(superpose.symbol=list(col=c("red", "blue"), fill=c("red", "blue"), pch=c(24, 25), cex=2)),
auto.key=list(space="right"))
回答1:
I have tried both your version and the version available at CRAN today (0.20-14). Both of them fail to fill the symbols of the legend. However, your code works correctly with version 0.20-10. Therefore, I am afraid you have found a bug. Could you send an email to the maintainer?
UPDATE: This bug has been fixed in version 0.20-15.
回答2:
Try: par.settings = list(strip.background=list(col="red"), superpose.symbol = list ( pch = c(17,19,22), col=c("red", "green", "blue" )))
来源:https://stackoverflow.com/questions/15441661/symbol-fill-color-in-lattice-using-auto-key