Learn R Programming

ellipse (version 0.2-3)

plotcorr: Plot correlation matrix ellipses

Description

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. It works best with the postscript output device.

Usage

plotcorr(corr, outline = TRUE, dev = FALSE, col = "grey", paropts = NULL, 
    numbers = FALSE, ...)

Arguments

corr
A matrix containing entries between -1 and 1 to be plotted as correlations. Use corr = NULL to execute plotcorr only for the side effect of opening the postscript device (see example belo
outline
Whether the ellipses should be outlined in the default colour.
dev
Which device to plot to. By default, continues to plot to the current device. If you want to produce a Postscript plot, use dev = postscript. Note that in order to install the fonts correctly, the first plot to a postscript device must
col
Which colour to use to fill the ellipses.
paropts
Layout and other plot options to use after the device is open. When plotcorr opens the device, par() options specified before you call it won't have any effect. Specify the options you need in a list here to affect the

item

  • numbers
  • ...

code

postscript

Side Effects

If dev specifies a graphics device, then this will open it. If dev is postscript, installs two ellipse-shaped fonts into the Postscript preamble: an outline font in the second last position, and a solid font in the last position. [Not implemented in this R version!] Produces a plot of the correlations on the given device or on the current device.

Details

The ellipses being plotted will be tangent to a unit character square, with the shape chosen to match the required correlation. On the postscript output device, plotting is done by installing special fonts for the ellipse shapes. On other devices, plotting is done using the ellipse() function. Postscript output is much, much faster than other devices.

References

Murdoch, D.J. and Chow, E.D. (1996). A graphical display of large correlation matrices. The American Statistician 50, 178-180.

See Also

ellipse

Examples

Run this code
# 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 to the same file, with numbers in place of the
# ellipses
plotcorr(summary(fit, correlation = TRUE)$correlation, numbers = TRUE)

Run the code above in your browser using DataLab