| Statistics Toolbox™ | ![]() |
gscatter(x,y,group)
gscatter(x,y,group,clr,sym,siz)
gscatter(x,y,group,clr,sym,siz,doleg)
gscatter(x,y,group,clr,sym,siz,doleg,xnam,ynam)
h = gscatter(...)
gscatter(x,y,group) creates a scatter plot of x and y, grouped by group. x and y are vectors of the same size. group is a grouping variable in the form of a categorical variable, vector, string array, or cell array of strings. (See Grouped Data.) Alternatively, group can be a cell array containing several grouping variables (such as {g1 g2 g3}), in which case observations are in the same group if they have common values of all grouping variables. Points in the same group and appear on the graph with the same marker and color.
gscatter(x,y,group,clr,sym,siz) specifies the color, marker type, and size for each group. clr is a string array of colors recognized by the plot function. The default for clr is 'bgrcmyk'. sym is a string array of symbols recognized by the plot command, with the default value '.'. siz is a vector of sizes, with the default determined by the 'DefaultLineMarkerSize' property. If you do not specify enough values for all groups, gscatter cycles through the specified values as needed.
gscatter(x,y,group,clr,sym,siz,doleg) controls whether a legend is displayed on the graph (doleg is 'on', the default) or not (doleg is 'off').
gscatter(x,y,group,clr,sym,siz,doleg,xnam,ynam) specifies the name to use for the x-axis and y-axis labels. If the x and y inputs are simple variable names and xnam and ynam are omitted, gscatter labels the axes with the variable names.
h = gscatter(...) returns an array of handles to the lines on the graph.
Load the cities data and look at the relationship between the ratings for climate (first column) and housing (second column) grouped by city size. We'll also specify the colors and plotting symbols.
load discrim gscatter(ratings(:,1),ratings(:,2),group,'br','xo')

gplotmatrix, grpstats, scatter
![]() | grpstats | hadamard | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |