Symbol fill color in lattice using auto.key

南楼画角 提交于 2020-01-03 17:14:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!