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,y,group)`

gplotmatrix(x,y,group,* clr*,

`sym`

gplotmatrix(x,y,group,

`clr`

`sym`

`doleg`

gplotmatrix(x,y,group,

`clr`

`sym`

`doleg`

`dispopt`

gplotmatrix(x,y,group,

`clr`

`sym`

`doleg`

`dispopt`

[h,ax,bigax] = gplotmatrix(...)

`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,`

specifies
the color, marker type, and size for each group. * clr*,

`sym`

`clr`

`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,`

controls
whether a legend is displayed on the graph (* clr*,

`sym`

`doleg`

`doleg`

`'on'`

, the default)
or not (`doleg`

`'off'`

).`gplotmatrix(x,y,group,`

controls
what appears along the diagonal of a plot matrix of * clr*,

`sym`

`doleg`

`dispopt`

`y`

versus `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. or `'variable'`

, to write the variable names. `gplotmatrix`

displays
histograms along the diagonal only when there is only one variable
(i.e., `gplotmatrix(x,[],[],[],[],[],[],'hist')`

.`gplotmatrix(x,y,group,`

specifies
the names of the columns in the * clr*,

`sym`

`doleg`

`dispopt`

`x`

and `y`

arrays.
These names are used to label the `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. `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?