如何控制格子xyplot中的椭圆颜色?

时间:2016-10-04 15:49:47

标签: r plot lattice

我想在ellipse colors内更改widthlattice xyplot。 这是一个例子:

library(lattice)
xyplot(Sepal.Length ~ Petal.Length, groups=Species,
       data = iris, scales = "free",
       par.settings = list(superpose.symbol = list(pch = 18, cex = 0.9,col = c("green", "orange","brown"),superpose.line = list(lwd=2))),
       panel = function(x, y, ...) {
           panel.xyplot(x, y, ...)
           panel.ellipse(x, y, ...)
       },
       auto.key = list(x = .1, y = .8, corner = c(0, 0)))

我想将椭圆颜色与点匹配并增加它们的宽度。 enter image description here

1 个答案:

答案 0 :(得分:2)

正如user20650的评论中所述,您可以向panel.ellipse功能添加其他选项。在这种情况下,您需要添加collwd选项。

library(lattice)
library(latticeExtra) # you forgot to mention this package in question

xyplot(Sepal.Length ~ Petal.Length, groups = Species, data = iris,
       scales = "free", auto.key = list(x = 0.1, y = 0.8, corner = c(0, 0)),
       par.settings = list(superpose.symbol = list(pch = 18, cex = 0.9,
                           col = c("green", "orange","brown"),
                           superpose.line = list(lwd=2))),
       panel = function(x, y, ...) {
           panel.xyplot(x, y, ...)
           panel.ellipse(x, y, col = c("green", "orange", "brown"), 
                         lwd = c(5, 5, 5), ...)
       }
)

enter image description here