plotmatrix(X,Y) creates
a matrix of subaxes containing scatter plots of the columns of X against
the columns of Y. If X is p-by-n and Y is p-by-m,
then plotmatrix produces an n-by-m matrix
of subaxes.

plotmatrix(X) is the
same as plotmatrix(X,X) except that the subaxes
along the diagonal are replaced with histogram plots of the data in
the corresponding column of X. For example, the
subaxes along the diagonal in the ith column
is replaced by hist(X(:,i)).

plotmatrix(___,LineSpec) specifies
the line style, marker symbol, and color for the scatter plots. The
option LineSpec can be preceded by any of the input
argument combinations in the previous syntaxes.

Initialize the random-number generator to make the output of randn repeatable. Define X as a matrix of normally distributed pseudorandom data and Y as a matrix of integer values.

rng default
X = randn(50,3);
Y = reshape(1:150,50,3);

Create a scatter plot matrix of the columns of X against the columns of Y.

figure
plotmatrix(X,Y)

The subplot in the ith row, jth column of the figure is a scatter plot of the ith column of Y against the jth column of X.

Initialize the random-number generator to make the output of randn repeatable and generate a matrix of normally distributed pseudorandom data

rng default
X = randn(50,3);

Create a scatter plot matrix.

figure
plotmatrix(X)

The subplot in the ith row, jth column of the matrix is a scatter plot of the ith column of X against the jth column of X. Along the diagonal, plotmatrix creates a histogram plot of each column of X.

Initialize the random-number generator to make the output of randn repeatable. Generate a matrix of normally distributed pseudorandom data.

rng default
X = randn(50,3);

Create a scatter plot matrix and return the object handles and the axes handles.

figure
[H,AX,BigAx,P,PAx] = plotmatrix(X);

To set properties for the scatter plots, use the handles in H. To set properties for the histograms, use the patch handles in P. To set axes properties, use the axes handles, AX, BigAx, and PAx. Starting in R2014b, you can use dot notation to set properties. If you are using an earlier release, use the set function instead.

Set the color and marker type for the scatter plot in the lower left corner.

H(3).Color = 'g';
H(3).Marker = '*';

Set the color for the histogram plot in the lower right corner. Use the title command to title the figure.

P(3).EdgeColor = 'k';
P(3).FaceColor = 'g';
title(BigAx,'A Comparison of Data Sets')

Line style, marker symbol, and color for the scatter plots,
specified as a string. For more information on line style, marker
symbol, and color options see LineSpec.

Line object handles, returned as a matrix. This is a unique
identifier, which you can use to query and modify the properties of
a specific line object. The line objects are used to create the scatter
plots.

Big axes handle, returned as a scalar. This is a unique identifier,
which you can use to query and modify properties of the big axes. BigAx is
left as the current axes (gca) so that a subsequent title, xlabel,
or ylabel command will center text with respect
to the big axes.

Patch object handles, returned as a vector or [].
If histogram plots are created, then P is returned
as a vector of patch object handles for the histogram plots. These
are unique identifiers, which you can use to query and modify the
properties of a specific patch object. If no histogram plots are created,
then P is returned as empty brackets.

Handle to invisible histogram axes, returned as a vector or [].
If histogram plots are created, then PAx is returned
as a vector of histogram axes handles. These are unique identifiers,
which you can use to query and modify the properties of a specific
axes, such as the axes scale. If no histogram plots are created, then PAx is
returned as empty brackets.