如何使用auto.key增加点阵中的点大小

时间:2012-02-17 16:46:48

标签: r lattice

使用格子的key参数,我可以设置键中符号的大小。我无法找到与auto.key相同的解决方案(与密钥相比具有许多优点)。将列表传递给点会引发“非逻辑”错误。

library(lattice)
# Works to set symbol size, but needs additional work to give text etc.
xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width | Species,
   data = iris, scales = "free", layout = c(2, 2),
   key = list(points=list(cex=2.5,pch=c(13,3,16)),x = .6, y = .7, corner = c(0, 0)))
# Fails
xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width | Species,
   data = iris, scales = "free", layout = c(2, 2),
   auto.key = list(points=list(cex=2.5,pch=c(13,3,16)),
      x = .6, y = .7, corner = c(0, 0)))

1 个答案:

答案 0 :(得分:5)

看看这是否为您提供了选项(改编自Sarkar关于auto.key的建议)。正在修改由simpleTheme设置的默认cex 3,因此绘制的点是cex = 1,但默认值会继续显示为与您相似的auto.key(除了我认为的颜色之外)更好,但口味会有所不同):

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width | Species,
                   data = iris, scales = "free", layout = c(2, 2), cex=1,
        par.settings = simpleTheme(col=c("blue","red"),
                                   pch=c(13,3,16), cex=3, lwd=2),
        auto.key = list(points=TRUE,text=c("","",""),
                        x = .6, y = .7, corner = c(0, 0)) )