Description Usage Arguments Details Author(s) References See Also Examples
This function plots a correlation matrix using ellipse-shaped glyphs for each entry. The ellipse represents a level curve of the density of a bivariate normal with the matching correlation.
This is a fork of the original plotcorr
function
from the ellipse package as at version 0.3-8.
The arguments numbers
, type
, and diag
have been
replaced by lower.panel
, upper.panel
, and
diag.panel
similar to pairs
.
This enables displaying numbers in one triangle and ellipses in the
other. However, there is no support for diag = FALSE
in the
original sense of the function.
1 2 3 4 5 |
corr |
A matrix containing entries between |
outline |
Whether the ellipses should be outlined in the default colour. |
col |
Which colour(s) to use to fill the ellipses (recycled to |
lower.panel, upper.panel, diag.panel |
each panel can be either |
bty, axes, xlab, ylab, asp, mar, cex.lab, ... |
Graphical parameters
which will be passed to |
cex |
Graphical parameter
which will be passed to |
The ellipses being plotted will be tangent to a unit character square, with the shape chosen to match the required correlation.
(of this fork) Sebastian Meyer, (of the original version) Duncan Murdoch
Murdoch, D.J. and Chow, E.D. (1996). A graphical display of large correlation matrices. The American Statistician 50, 178-180.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if (requireNamespace("ellipse")) {
## Plot the correlation matrix for the mtcars data full model fit
data("mtcars")
fit <- lm(mpg ~ ., mtcars)
corr.fit <- summary(fit, correlation = TRUE)$correlation
plotcorr(corr.fit, col = "gray")
## with default color coding
plotcorr(corr.fit, col = TRUE)
## Colour the ellipses and order by correlations with miles/gallon
corr.mtcars <- cor(mtcars)
ord <- order(corr.mtcars[1,])
xc <- corr.mtcars[ord, ord]
colors <- colorRampPalette(c("blue", "white", "red"))(11)
plotcorr(xc, col = colors[5*xc + 6])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.