plotCCA: Plot a canonical correlation analysis solution

plotCCAR Documentation

Plot a canonical correlation analysis solution

Description

Visualize the canonical correlation solution produced by multiUS::cancorPlus. The function displays the first show canonical dimensions together with the corresponding coefficients for the X and Y variable sets. You can plot either regression coefficients (canonical weights) or canonical structure correlations, and optionally color the printed values according to their sign and magnitude.

Variable labels can be taken from row names of ccRes$xcoef and ccRes$ycoef, replaced with customNames, or generated automatically when row names are missing.

Usage

plotCCA(
  ccRes,
  xTitle = "X",
  yTitle = "Y",
  inColors = TRUE,
  show = NULL,
  scaleLabelsFactor = 1/2,
  what = "reg",
  nDigits = 2,
  mar = c(1, 2, 1, 1),
  gapLeft = 0,
  customNames = NULL
)

Arguments

ccRes

The output of multiUS::cancorPlus.

xTitle

Character string used as the label for the first (X) set of variables.

yTitle

Character string used as the label for the second (Y) set of variables.

inColors

Logical; should values be shown in color (TRUE, default) or in black (FALSE)? When TRUE, positive values are shown in blue tones and negative values in red tones, with intensity reflecting magnitude.

show

Integer; number of canonical dimensions to display. If NULL (default), all canonical correlations in ccRes$cor are shown.

scaleLabelsFactor

Numeric exponent controlling the size of the printed coefficients. Label size is proportional to abs(value)^scaleLabelsFactor + 0.2. Default is 1/2.

what

Character string specifying what should be plotted: "reg" for regression coefficients (default) or "cor" for canonical structure correlations. If what = "cor" but the required correlation components are unavailable in ccRes$scores, the function falls back to regression coefficients and issues a warning.

nDigits

Integer; number of decimal places used when printing the values.

mar

Numeric vector of plot margins passed to graphics::par. Default is c(1, 2, 1, 1).

gapLeft

Integer; number of empty columns inserted before the first canonical dimension. Useful for aligning multiple plots. Default is 0.

customNames

Optional named character vector or list used to relabel variables. Names should correspond to variable names in rownames(ccRes$xcoef) and/or rownames(ccRes$ycoef). If provided, matched variables are replaced by the supplied labels.

Value

This function is called for its side effect of drawing a plot and returns NULL invisibly.

Author(s)

Marjan Cugmas

Examples

tmp <- cancorPlus(
  x = mtcars[, c(1, 2, 3)],
  y = mtcars[, c(4, 5, 6)],
  useCCApackage = TRUE
)

plotCCA(
  tmp,
  scaleLabelsFactor = 1/2,
  what = "cor",
  customNames = c("cyl" = "Cylinders")
)


multiUS documentation built on April 27, 2026, 3:04 a.m.

Related to plotCCA in multiUS...