Description Usage Arguments Value Author(s) See Also Examples
ell
is a utility function used to calculate the (X, Y) coordinates of a 2D ellipse
for the purpose of drawing statistical diagrams and plots.
ellplus
can produce, in addition to the points of an ellipse, the
conjugate axes corresponding to a chol
or other decomposition
and the surrounding parallelogram defined by these axes.
1 2 3 |
center |
X,Y location of the center of the ellipse |
shape |
A 2x2 matrix, typically a covariance matrix of data (for a data ellipse), or a covariance matrix of estimated parameters in a model (for a confidence ellipse). |
radius |
Radius of the ellipse-generating unit circle. The default, |
n |
Number of points on the unit circle used to calculate the ellipse |
angles |
Angles around the unit circle used to calculate the ellipse |
fac |
A function defining the conjugate axes used to transform the unit circle
into an ellipse. The default, |
ellipse |
Logical to indicate if the points on the ellipse should be returned |
diameters |
Logical to indicate if the points defining the ends of the conjugate axes of the ellipse should be returned |
box |
Logical to indicate if the points on the conjugate-axes bounding box should be returned |
all |
Logical to request all of |
Returns a 2-column matrix of (X,Y) coordinates suitable for drawing with
lines()
.
For ellplus
, when more than one of the options ellipse
, diameters
,
and box
is TRUE
, the different parts are separated by a row of NA
.
Georges Monette
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | plot( x=0,y=0, xlim = c(-3,3), ylim = c(-3,3),
xlab = '', ylab = '', type = 'n', asp=1)
abline( v=0, col="gray")
abline( h=0, col="gray")
A <- cbind( c(1,2), c(1.5,1))
W <- A %*% t(A)
lines( ell(center=c(0,0), shape = W ), col = 'blue', lwd=3)
lines( ellplus(center=c(0,0), shape = W, box=TRUE, diameters=TRUE ), col = 'red')
# show conjugate axes for PCA factorization
pca.fac <- function(x) {
xx <- svd(x)
ret <- t(xx$v) * sqrt(pmax( xx$d,0))
ret
}
plot( x=0,y=0, xlim = c(-3,3), ylim = c(-3,3),
xlab = '', ylab = '', type = 'n', asp=1)
abline( v=0, col="gray")
abline( h=0, col="gray")
lines( ell(center=c(0,0), shape = W ), col = 'blue', lwd=3)
lines( ellplus(center=c(0,0), shape = W, box=TRUE, diameters=TRUE, fac=pca.fac ), col = 'red')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.