gscatter
Draw a scatter plot with grouped data.
gscatter is a utility function to draw a scatter plot of x and
y, according to the groups defined by g. Input x and
y are numeric vectors of the same size, while g is either a
vector of the same size as x or a character matrix with the same number
of rows as the size of x. As a vector g can be numeric, logical,
a character array, a string array (not implemented), a cell string or cell
array.
A number of optional inputs change the appearance of the plot:
gscatter cycles through the specified colors. Colors can
be defined as named colors, as rgb triplets or as indices for the current
colormap. The default value is a different color for each group,
according to the current colormap.
gscatter cycles through the specified symbols.
gscatter cycles through the specified sizes.
on (default)
or off.
Output h is an array of graphics handles to the line object of
each group.
See also: scatter
Source Code: gscatter
load fisheriris;
X = meas(:,3:4);
cidcs = kmeans (X, 3, "Replicates", 5);
gscatter (X(:,1), X(:,2), cidcs, [.75 .75 0; 0 .75 .75; .75 0 .75], "os^");
title ("Fisher's iris data");
|