make_rect: Add a rectangle to a correlation plot

Description Usage Arguments Examples

View source: R/corrplot-rectangles.R

Description

Add a rectangle to a correlation plot

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
make_rect(
  rstart,
  rend,
  cstart = NULL,
  cend = NULL,
  correlation_matrix,
  mirror = FALSE,
  lwd = 3,
  ...
)

Arguments

rstart

The name of the variable contained in the correlation plot that will serve as the vertical starting point of the rectangle.

rend

The name of the variable contained in the correlation plot that will serve as the vertical ending point of the rectangle.

cstart

(optional) The name of the variable contained in the correlation plot that will serve as the horizontal starting point of the rectangle. If no cstart or cend provided, creates an on-diagonal rectangle automatically. cstart and cend allows for off-diagonal rectangles.

cend

(optional) The name of the variable contained in the correlation plot that will serve as the horizontal ending point of the rectangle. If no cstart or cend provided, creates an on-diagonal rectangle automatically. cstart and cend allows for off-diagonal rectangles.

correlation_matrix

The correlation matrix the correlation plot is based on.

mirror

If TRUE, also adds the equivalent rectangle from the other side of the diagonal (i.e. the "mirror" of the original). The function ignores this entirely if the rectangle is on the diagonal, as there is no mirror.

lwd

Determines the width of the rectangle lines.

...

Arguments to modify graphical parameters, etc.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#Adding an on-diagonal rectangle to a correlation plot with mirroring, using
#the Bechtoldt sample correlation matrix provided by the psych package.
library(corrplot)
library(psych)
corrplot(Bechtoldt)
make_rect(rstart="First_Names", rend="Flags", correlation_matrix=Bechtoldt, mirror=TRUE)

#Adding an off-diagonal rectangle
make_rect(rstart="First_Names", rend="Flags", cstart="First_Names",
cend="Sentences", correlation_matrix=Bechtoldt)

douglaswhitaker/MVQuickGraphs documentation built on Sept. 18, 2021, 7:17 p.m.