# plotmatrix

Scatter plot matrix

The behavior of `[S,Ax,BigAx,H,HAx] = plotmatrix(_)` changed in R2015b. The output argument `H` now contains histogram objects instead of patch objects.

## Syntax

• ``plotmatrix(X,Y)``
example
• ``plotmatrix(X)``
example
• ``plotmatrix(___,LineSpec)``
example
• ``````[S,AX,BigAx,H,HAx] = plotmatrix(___)``````
example

## Description

example

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

example

````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 `histogram(X(:,i))`.```

example

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

example

``````[S,AX,BigAx,H,HAx] = plotmatrix(___)``` returns the graphic objects created as follows:`S` – Chart line objects for the scatter plots`AX` – Axes objects for each subaxes`BigAx` – Axes object for big axes that frames the subaxes`H` – Histogram objects for the histogram plots`HAx` – Axes objects for the invisible histogram axes`BigAx` is left as the current axes (`gca`) so that a subsequent `title`, `xlabel`, or `ylabel` command centers text with respect to the big axes.```

## Examples

collapse all

### Create Scatter Plot Matrix with Two Matrix Inputs

Create `X` as a matrix of random data and `Y` as a matrix of integer values. Then, create a scatter plot matrix of the columns of `X` against the columns of `Y`.

```X = randn(50,3); Y = reshape(1:150,50,3); 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`.

### Create Scatter Plot Matrix with One Matrix Input

Create a scatter plot matrix of random data. 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 are histogram plots of each column of `X`.

```X = randn(50,3); plotmatrix(X) ```

### Specify Marker Type and Color

Create a scatter plot matrix of random data. Specify the marker type and the color for the scatter plots.

```X = randn(50,3); plotmatrix(X,'*r') ```

The `LineSpec` option sets properties for the scatter plots. To set properties for the histogram plots, return the histogram objects.

### Modify Scatter Plot Matrix After Creation

Create a scatter plot matrix of random data.

```rng default X = randn(50,3); [S,AX,BigAx,H,HAx] = plotmatrix(X); ```

To set properties for the scatter plots, use `S`. To set properties for the histograms, use `H`. To set axes properties, use `AX`, `BigAx`, and `HAx`. 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 of the figure. Set the color for the histogram plot in the lower right corner. Use the `title` command to title the figure.

```S(3).Color = 'g'; S(3).Marker = '*'; H(3).EdgeColor = 'k'; H(3).FaceColor = 'g'; title(BigAx,'A Comparison of Data Sets') ```

## Input Arguments

collapse all

### `X` — Data to displaymatrix

Data to display, specified as a matrix.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical`

### `Y` — Data to plot against `X`matrix

Data to plot against `X`, specified as a matrix.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical`

### `LineSpec` — Line style, marker symbol, and color for scatter plotsstring

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

Example: `':*r'`

## Output Arguments

collapse all

### `S` — Chart line objects for scatter plotsmatrix

Chart line objects for the scatter plots, returned as a matrix. These are unique identifiers, which you can use to query and modify the properties of a specific scatter plot.

### `AX` — Axes objects for subaxesmatrix

Axes objects for the subaxes, returned as a matrix. These are unique identifiers, which you can use to query and modify the properties of a specific subaxes.

### `BigAx` — Axes object for big axesscalar

Axes object for big axes, returned as a scalar. This is a unique identifier, which you can use to query and modify properties of the big axes.

### `H` — Histogram objectsvector | []

Histogram objects, returned as a vector or `[]`. These are unique identifiers, which you can use to query and modify the properties of a specific histogram object. If no histogram plots are created, then `H` is returned as empty brackets.

### `HAx` — Axes objects for invisible histogram axesvector | []

Axes objects for invisible histogram axes, returned as a vector or `[]`. These are unique identifiers, which you can use to query and modify the properties of a specific axes. If no histogram plots are created, then `HAx` is returned as empty brackets.