Description Usage Arguments Author(s) Examples
View source: R/panel.ellipse.R
A lattice panel function that computes and draws a confidence ellipsoid from bivariate data, possibly grouped by a third variable.
1 2 3 4 
x, y 
Numeric vectors of same length giving the bivariate data. Nonnumeric variables will be coerced to be numeric. 
groups 
Optional grouping variable. 
level 
Confidence level for the ellipse. 
segments 
Number of segments used to approximate the ellipse. 
robust 
Logical indicating whether a robust method should be used. If

center.pch 
Plotting character for the center (fitted mean). If 
center.cex 
Character expansion (size) multipler for the symbol indicating the center. 
... 
Further arguments, typically graphical parameters. Passed on to

type, pch, cex 
Parameters that are ignored; these are present only to make sure
they are not inadvertently passed on to 
Deepayan Sarkar, extending code contributed by Michael Friendly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43  xyplot(Sepal.Length ~ Petal.Length, groups=Species,
data = iris, scales = "free",
par.settings = list(superpose.symbol = list(pch=c(15:17)),
superpose.line = list(lwd=2, lty=1:3)),
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.ellipse(x, y, ...)
},
auto.key = list(x = .1, y = .8, corner = c(0, 0)))
## Without groups
xyplot(Sepal.Length ~ Petal.Length,
data = iris, scales = "free",
par.settings = list(plot.symbol = list(cex = 1.1, pch=16)),
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.ellipse(x, y, lwd = 2, ...)
},
auto.key = list(x = .1, y = .8, corner = c(0, 0)))
## With conditioning
xyplot(Sepal.Length ~ Petal.Length  Species,
data = iris, scales = "free",
par.settings = list(plot.symbol = list(cex = 1.1, pch=16)),
layout=c(2,2),
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.ellipse(x, y, lwd = 2, ...)
},
auto.key = list(x = .6, y = .8, corner = c(0, 0)))
## Compare classical with robust
xyplot(Sepal.Length ~ Petal.Length  Species,
data = iris, scales = "free",
par.settings = list(plot.symbol = list(cex = 1.1, pch=16)),
layout=c(2,2),
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.ellipse(x, y, lwd = 2, ...)
panel.ellipse(x, y, lwd = 2, col="red", robust=TRUE, ...)
})

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.