biplot

Syntax

biplot(coefs)
h = biplot(coefs,'Name',Value)

Description

biplot(coefs) creates a biplot of the coefficients in the matrix coefs. The biplot is 2-D if coefs has two columns or 3-D if it has three columns. coefs usually contains principal component coefficients created with pca, pcacov, or factor loadings estimated with factoran. The axes in the biplot represent the principal components or latent factors (columns of coefs), and the observed variables (rows of coefs) are represented as vectors.

A biplot allows you to visualize the magnitude and sign of each variable's contribution to the first two or three principal components, and how each observation is represented in terms of those components.

biplot imposes a sign convention, forcing the element with largest magnitude in each column of coefs to be positive. This flips some of the vectors in coefs to the opposite direction, but often makes the plot easier to read. Interpretation of the plot is unaffected, because changing the sign of a coefficient vector does not change its meaning.

biplot scales the scores so that they fit on the plot: It divides each score by the maximum absolute value of all scores, and multiplies by the maximum coefficient length of coefs. Then biplot changes the sign of score coordinates according to the sign convention for the coefs.

h = biplot(coefs,'Name',Value) specifies one or more name/value input pairs and returns a column vector of handles to the graphics objects created by biplot. The h contains, in order, handles corresponding to variables (line handles, followed by marker handles, followed by text handles), to observations (if present, marker handles followed by text handles), and to the axis lines.

Input Arguments

Name-Value Pair Arguments

'Scores'

Plots both coefs and the scores in the matrix scores in the biplot. scores usually contains principal component scores created with pca or factor scores estimated with factoran. Each observation (row of scores) is represented as a point in the biplot.

'VarLabels'

Labels each vector (variable) with the text in the character array or cell array varlabels.

'ObsLabels'

Uses the text in the character array or cell array obslabels as observation names when displaying data cursors.

'Positive'

  • 'true' — restricts the biplot to the positive quadrant (in 2-D) or octant (in 3-D).

  • 'false' — makes the biplot over the range +/- max(coefs(:)) for all coordinates.

Default: false

'PropertyName'

Specifies optional property name/value pairs for all Primitive Line Properties graphics objects created by biplot.

Examples

expand all

Biplot of Coefficients and Scores

Load the sample data.

load carsmall

Define the variable matrix and delete the rows with missing values.

x = [Acceleration Displacement Horsepower MPG Weight];
x = x(all(~isnan(x),2),:);

Perform a principal component analysis of the data.

[coefs,score] = pca(zscore(x));

View the data and the original variables in the space of the first three principal components.

vbls = {'Accel','Disp','HP','MPG','Wgt'};
biplot(coefs(:,1:3),'scores',score(:,1:3),'varlabels',vbls);

Was this topic helpful?