plotcorr {ellipse} | 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 = "grey", numbers = FALSE, ...)
corr |
A matrix containing entries between -1 and 1 to be plotted as
correlations.
|
outline |
Whether the ellipses should be outlined in the default colour. |
col |
Which colour(s) to use to fill the ellipses. |
numbers |
Whether to plot numerical correlations in place of ellipses. If
numbers is TRUE , then the correlations will be rounded to a single decimal
place and placed on the plot.
|
... |
Additional graphical parameters. |
The ellipses being plotted will be tangent to a unit character square,
with the shape chosen to match the required correlation. If numbers = FALSE
,
the col
vector will be recycled to colour each of the ellipses; if
TRUE
, it will be ignored.
Murdoch, D.J. and Chow, E.D. (1996). A graphical display of large correlation matrices. The American Statistician 50, 178-180.
save.par <- par(ask = TRUE) # Plot the correlation matrix for the mtcars data full model fit data(mtcars) fit <- lm(mpg ~ ., mtcars) plotcorr(summary(fit, correlation = TRUE)$correlation) # Plot a second figure with numbers in place of the # ellipses plotcorr(summary(fit, correlation = TRUE)$correlation, numbers = TRUE) # Colour the ellipses to emphasize the differences corr.mtcars <- cor(mtcars) ord <- order(corr.mtcars[1,]) xc <- corr.mtcars[ord, ord] plotcorr( xc, col=cm.colors(11)[5*xc + 6]) par(save.par)