| plotcorr | R Documentation |
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.
plotcorr(
corr,
outline = TRUE,
col = TRUE,
lower.panel = "ellipse",
upper.panel = "number",
diag.panel = NULL,
bty = "n",
axes = FALSE,
xlab = "",
ylab = "",
asp = 1,
cex.lab = par("cex.lab"),
cex = 0.75 * par("cex"),
mar = 0.1 + c(2, 2, 4, 2),
...
)
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 |
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.
The ellipses being plotted will be tangent to a unit character square, with the shape chosen to match the required correlation.
Sebastian Meyer, Duncan Murdoch
Murdoch, D.J. and Chow, E.D. (1996). A graphical display of large correlation matrices. The American Statistician 50, 178-180.
plotcorr
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.