sfa_corplot: Heatmap of an Item-by-Item Similarity Matrix

View source: R/corplot.R

sfa_corplotR Documentation

Heatmap of an Item-by-Item Similarity Matrix

Description

Draws a cor.plot heatmap of a semantic similarity matrix with sensible defaults for a many-item scale. By default the items are grouped by their subscale/factor (so each construct forms a block on the diagonal), the bulky transformed-embeddings attribute is removed, and all axis labels are shown.

Usage

sfa_corplot(
  x,
  factors = NULL,
  labels = NULL,
  group = TRUE,
  order = NULL,
  numbers = FALSE,
  upper = TRUE,
  gap.axis = -1,
  cex.axis = 0.75,
  xlas = 2,
  ...
)

Arguments

x

An "sfa" object, or a similarity matrix from sfa_similarity.

factors

Optional per-item subscale labels used to group the items. For an "sfa" object, defaults to its theoretical factors; for a matrix, defaults to a "factors" attribute if present.

labels

Optional per-item axis labels. By default uses short item codes (the code column for an "sfa" object, or a "codes" attribute / short dimnames on a matrix). If only sentence-like labels are available, compact codes are generated from the factors (e.g. A1, A2, D1, ...) rather than printing full item text.

group

Logical: reorder items so each factor forms a contiguous block (default TRUE). Ignored when no factors are available.

order

Optional character vector giving the order of the factor blocks (default: alphabetical). Entries are matched to the factor labels by exact, case-insensitive, or unique-prefix match, so for Depression/Anxiety/Stress both c("Depression","Anxiety","Stress") and c("D","A","S") work. A non-matching or ambiguous entry is an error; any factors omitted from order are appended after the listed ones.

numbers, upper, gap.axis, cex.axis, xlas

Passed to cor.plot; defaults are tuned for a many-item matrix (no in-cell numbers, upper triangle, every label shown, small label text).

...

Further arguments passed to cor.plot.

Details

Grouping happens only for display — the underlying similarity matrix from sfa_similarity keeps its original item order (rows aligned with the items' scoring, codes, and embeddings), which the rest of the package relies on.

Value

The (grouped, relabelled) matrix that was plotted, invisibly.

See Also

sfa_similarity, sfa

Examples

data(big5)
fit <- sfa(
  data.frame(code = big5$codes, item = big5$items,
             factor = big5$factors, scoring = big5$scoring),
  embeddings = big5$embeddings, scoring = big5$scoring, nfactors = 5)

sfa_corplot(fit)                      # heatmap, grouped by the Big Five

semanticfa documentation built on Sept. 2, 2026, 1:07 a.m.