如何控制格子xyplot中的椭圆颜色?
How to control ellipse colors in lattice xyplot?
我想在 lattice xyplot
内更改 ellipse colors
和 width
。
这是一个例子:
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)))
我想将椭圆颜色与点匹配并增加它们的宽度。
如 user20650
评论中所述,您可以向 panel.ellipse
函数添加其他选项。在这种情况下,您要添加 col
和 lwd
选项。
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), ...)
}
)
我想在 lattice xyplot
内更改 ellipse colors
和 width
。
这是一个例子:
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)))
我想将椭圆颜色与点匹配并增加它们的宽度。
如 user20650
评论中所述,您可以向 panel.ellipse
函数添加其他选项。在这种情况下,您要添加 col
和 lwd
选项。
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), ...)
}
)