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.
The following code
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");
Produces the following output
warning: load: '/home/nir/Documents/octave-hg/octave-statistics/target/.installation/statistics-1.4.3/fisheriris.mat' found by searching load path
warning: called from
get_output at line 50 column 5
__html_help_text__ at line 67 column 28
generate_package_html>wrote_html at line 842 column 5
generate_package_html at line 207 column 7
and the following figure
| Figure 1 |
|---|
![]() |
Package: statistics