使用auto.key在格子中填充符号的颜色 [英] Symbol fill color in lattice using auto.key
问题描述
我正在使用lattice
(R 15.2,晶格0.20-13)中的xyplot
进行绘图,其中我想通过标记的形状区分几个组.我需要使用一个向下的三角形,该三角形只能作为空心符号(pch=25
)使用,而向上的三角形则可以用作实心(pch=17
)或空心(pch=24
)符号.我可以在par.settings(superpose.line())
中为这些符号指定轮廓色和填充色,但是当我绘制auto.key
时,没有填充.有什么方法可以使auto.key
与绘图符号一致?
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"))
推荐答案
我已经尝试了您的版本和今天(0.20-14)在CRAN 可用.他们两个都无法填充图例的符号.但是,您的代码在版本 0.20下正确运行-10 .因此,恐怕您发现了一个错误.您可以发送电子邮件给维护者吗?
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?
更新:此错误已在0.20-15版中修复.
UPDATE: This bug has been fixed in version 0.20-15.
这篇关于使用auto.key在格子中填充符号的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!