Documentation

plotmatrix

Scatter plot matrix

Syntax

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

Description

example

plotmatrix(X,Y)创建一个米atrix of subaxes containing scatter plots of the columns ofXagainst the columns ofY. IfXisp-by-nandYisp-by-m, thenplotmatrixproduces ann-by-mmatrix of subaxes.

example

plotmatrix(X)is the same asplotmatrix(X,X)except that the subaxes along the diagonal are replaced with histogram plots of the data in the corresponding column ofX. For example, the subaxes along the diagonal in theith column is replaced byhistogram(X(:,i)).

example

plotmatrix(___,LineSpec)specifies the line style, marker symbol, and color for the scatter plots. The optionLineSpeccan 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

BigAxis left as the current axes (gca) so that a subsequenttitle,xlabel, orylabelcommand centers text with respect to the big axes.

Examples

collapse all

CreateXas a matrix of random data andYas a matrix of integer values. Then, create a scatter plot matrix of the columns ofXagainst the columns ofY.

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 ofYagainst the jth column ofX.

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 ofXagainst the jth column ofX. Along the diagonal are histogram plots of each column ofX.

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

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')

TheLineSpecoption sets properties for the scatter plots. To set properties for the histogram plots, return the histogram objects.

Create a scatter plot matrix of random data.

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

To set properties for the scatter plots, useS. To set properties for the histograms, useH. To set axes properties, useAX,BigAx, andHAx. Starting in R2014b, you can use dot notation to set properties. If you are using an earlier release, use thesetfunction 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 thetitlecommand 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

Data to display, specified as a matrix.

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

Data to plot againstX, specified as a matrix.

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

Line style, marker symbol, and color for the scatter plots, specified as a character vector or string. For more information on line style, marker symbol, and color options seeLineSpec.

例子:':*r'

Output Arguments

collapse all

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.

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.

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.

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, thenHis returned as empty brackets.

Note

Starting in R2015b,His a vector of histogram objects, In previous releases, it was a vector of patch objects.

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, thenHAxis returned as empty brackets.

See Also

|

Introduced before R2006a

Was this topic helpful?