Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Matrix of scatter plots by group

`gplotmatrix(x,[],group)`

`gplotmatrix(x,y,group)`

`gplotmatrix(x,y,group,clr,sym,siz)`

`gplotmatrix(x,y,group,clr,sym,siz,doleg)`

`gplotmatrix(x,[],group,clr,sym,siz,doleg,dispopt)`

`gplotmatrix(x,[],group,clr,sym,siz,doleg,'variable',xnam)`

`gplotmatrix(x,y,group,clr,sym,siz,doleg,[],xnam,ynam)`

`[h,ax,bigax] = gplotmatrix(___)`

`gplotmatrix(x,[],group)`

creates a matrix of scatter plots of
the data in `x`

, grouped by the grouping variable in
`group`

. Each individual set of axes in the resulting figure
contains a scatter plot of a column of `x`

against another column
of `x`

. It also plots the outlines of the grouped historgrams in
the diagonals.

`gplotmatrix(x,y,group)`

creates a matrix
of scatter plots. Each individual set of axes in the resulting figure contains a
scatter plot of a column of `x`

against a column of
`y`

. All plots are grouped by the grouping variable
`group`

.

`x`

and `y`

are matrices with the same number of
rows. If `x`

has *p* columns and
`y`

has *q* columns, the figure contains a
*p*-by-*q* matrix of scatter plots. If you
omit `y`

or specify it as the empty matrix, `[]`

,
`gplotmatrix`

creates a square matrix of scatter plots of
columns of `x`

against each other.

`group`

is a grouping variable that can be a categorical
variable, vector, character array, or cell array of character vectors.
`group`

must have the same number of rows as
`x`

and `y`

. Points with the same value of
`group`

are placed in the same group, and appear on the graph
with the same marker and color. Alternatively, `group`

can be a
cell array containing several grouping variables (such as ```
{g1 g2
g3}
```

); in that case, observations are in the same group if they have
common values of all grouping variables.

`gplotmatrix(x,y,group,clr,sym,siz)`

specifies the color, marker type, and size for each group.
* clr* is a character array of colors recognized by the

`plot`

function.
`sym`

`plot`

command, with the default value `'.'`

.
`siz`

is a vector of sizes, with the default value determined
based on the number of observations. If you do not specify enough values for all
groups, `gplotmatrix`

cycles through the specified values as
needed.`gplotmatrix(x,y,group,clr,sym,siz,doleg)`

controls whether a
legend is displayed on the graph
(* doleg* is

`'on'`

, the
default) or not
(`doleg`

`'off'`

).`gplotmatrix(x,[],group,clr,sym,siz,doleg,dispopt)`

controls what appears along the diagonal of a plot matrix of `x`

.
Allowable values are `'none'`

, to leave the diagonals blank,
`'hist'`

, to plot histograms, `'stairs'`

to
display the outlines of grouped histograms (default if there is more than one
group), `'grpbars'`

to plot grouped histogram bars.

`gplotmatrix(x,[],group,clr,sym,siz,doleg,'variable',xnam)`

displays the variable names along the diagonal of the plot matrix of
`x`

. It also uses these column names to label the
*x-* and *y*-axes.

`gplotmatrix(x,y,group,clr,sym,siz,doleg,[],xnam,ynam)`

labels
the *x-* and *y*-axes using the column names
specified in `xnam`

and `ynam`

.

`xnam`

and `ynam`

must be character arrays or
cell arrays of character vectors, with one name for each column of
`x`

and `y`

, respectively.

`[h,ax,bigax] = gplotmatrix(___)`

returns three arrays of handles for any of the previous input arguments.
`h`

is an array of handles to the lines on the graphs. The
array's third dimension corresponds to groups in the input argument
`group`

. `ax`

is a matrix of handles to the
axes of the individual plots. If

is
`dispopt`

`'hist'`

, `'stairs'`

, or
`'grpbars'`

, `ax`

contains one extra row of
handles to invisible axes in which the histograms are plotted.
`bigax`

is a handle to big (invisible) axes framing the entire
plot matrix. `bigax`

is fixed to point to the current axes, so a
subsequent `title`

, `xlabel`

, or
`ylabel`

command will produce labels that are centered with
respect to the entire plot matrix.

Was this topic helpful?